Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Codu And Sum Love:

Problem Description
```

Scanner sc = new Scanner(System.in);

long sum = 0;

int N = sc.nextInt();

for (int i = 0; i < N; i++) {

final long x = sc.nextLong(); // read input

String str = Long.toString((long) Math.pow(1 << 1, x));

str = str.length() > 2 ? str.substring(str.length() - 2) : str;

sum += Integer.parseInt(str);

}

System.out.println(sum%100);

```

Given N number of x’'s, perform logic equivalent of the above Java code and print the output

Constraints
1<=N<=10^7 0<=x<=10^18

Input Format
First line contains an integer N

Second line will contain N numbers delimited by space

Output
Number that is the output of the given code by taking inputs as specified above


Explanation
Example 1


Input
4 8 6 7 4
Output
64

Example 2

Input

3

1 2 3

Output

14

What I have tried:

Please solve this!
i have getting the error of memory limit exceed.
please can i have better solution?
Posted
Updated 10-Aug-18 7:56am
Comments
Mohibur Rashid 10-Aug-18 3:19am    
not an ideal question for this forum

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
This is a coding challenge/contest, it is set to test your coding skills. Since you ask us to do it, the answer is that you need to sharpen your skills because you are unable to solve the problem yourself.
You posted the question in a way that prevent any help.
In this kind of challenge, every word matters. So you need to post exact statement.
A link to actual page of challenge is a good idea too.
Quote:
Given N number of x’'s, perform logic equivalent of the above Java code and print the output

The logic equivalent of the code is the code itself.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work.
 
Share this answer
 
import java.util.Scanner;

public class Test
{
public void method()
{
Scanner sc = new Scanner(System.in);

long sum = 0;

int N = sc.nextInt();

for (int i = 0; i < N; i++) {

final long x = sc.nextLong(); // read input

String str = Long.toString((long) Math.pow(1 << 1, x));

str = str.length() > 2 ? str.substring(str.length() - 2) : str;

sum += Integer.parseInt(str);

}
System.out.println(sum%100);
}
public static void main(String args[])
{
Test t=new Test();
t.method();
}
}
 
Share this answer
 
Comments
Patrice T 10-Aug-18 17:31pm    
Why did you post the code from question ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900