我怎么解决这个问题,我无法解决 [英] How do I solve this, I am unable to solve

查看:89
本文介绍了我怎么解决这个问题,我无法解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Codu和Sum Love:



问题描述

` `



扫描仪sc =新扫描仪(System.in);



long sum = 0; < br $> b $ b

int N = sc.nextInt();



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



final long x = sc.nextLong(); //读取输入



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



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



sum + = Integer.parseInt(str);

< br $>
}



System.out.println(总和%100);



```



给定N个x',执行相当于上述Java代码的逻辑并打印输出



约束

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



输入格式

第一行包含一个整数N



第二行将包含由空格分隔的N个数字



输出

通过获取上述指定输入的给定代码的数字





说明

示例1





输入

4 8 6 7 4

输出

64



例2



输入



3



1 2 3



输出



14



我的尝试:



请解决这个问题!

i有超出内存限制的错误。

请问我能有更好的解决方案吗?

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?

推荐答案

我们不做你的作业:它是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但是我们不打算为你做这一切!
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!


这是一个编码挑战/比赛,它将测试你的编码技巧。既然你要求我们这样做,答案就是你需要提高你的技能,因为你自己无法解决问题。

你以一种阻止任何帮助的方式发布了这个问题。 />
在这种挑战中,每个词都很重要。所以你需要发布确切的声明。

链接到实际的挑战页面也是一个好主意。

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:

给定N个x',执行相当于上述Java代码的逻辑并打印输出

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



代码的逻辑等效于代码本身。



我们不做你的家庭作业。

HomeWork不会测试你乞求别人做你的工作的技巧。


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.


import java.util.Scanner;



公共类测试

{

公共无效方法()

{

扫描仪sc =新扫描仪(System.in);



长期总和= 0;



int N = sc.nextInt();



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



final long x = sc.nextLong(); //读取输入



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



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



sum + = Integer.parseInt(str);

< br $>
}

System.out.println(总和%100);

}

public static void main(String args [])

{

测试t =新测试();

t.method();

}

}
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();
}
}


这篇关于我怎么解决这个问题,我无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆