hdoj1032 3n+1问题 time limit exceeded
来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/05/01 04:45:29
hdoj1032 3n+1问题 time limit exceeded
#include
int main(void){
int i=0,j=0,n=1,temp=0;
while((scanf("%d %d",&i,&j))!=EOF){
temp=j;
n=1;
while(temp!=i){
if (temp%2==0) {
temp=temp/2;
n++;
}
else {
temp=3*temp+1;
n++;
}
}
printf("%d %d %d\n",i,j,n);
}
}
#include
int main(void){
int i=0,j=0,n=1,temp=0;
while((scanf("%d %d",&i,&j))!=EOF){
temp=j;
n=1;
while(temp!=i){
if (temp%2==0) {
temp=temp/2;
n++;
}
else {
temp=3*temp+1;
n++;
}
}
printf("%d %d %d\n",i,j,n);
}
}
说明你的程序效率太低,超时了!
再问: 是不是只能改方法了。。
再答: 嗯,优化一下把
再问: 是不是只能改方法了。。
再答: 嗯,优化一下把
hdoj1032 3n+1问题 time limit exceeded
Time Limit Exceeded和Output Limit Exceeded有什么不同,还是一样的?
ACM 的一道题提交总是Time Limit Exceeded,求救
Bandwidth Limit Exceeded
Output Limit Exceeded这是什么意思?
Call limit is exceeded for your IP
杭电里面的Output Limit Exceeded
杭电ACM2006提示Output Limit Exceeded,
IP Connection Limit Exceeded如何解决
user limit exceeded check your license的汉语意思是什么?
C++的问题 整数的因子数 Time Limit:2000MS Memory Limit:32768K
TIME LIMIT怎么样