I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
我晕难道南开的服务器是网通的??这会进N次进不去了
TO:雨中飞燕
不试过我怎么会乱说话呢?
看来你不知道EOF为何物
你不超时才怪,肯定死循环
by 雨中飞燕 QQ:78803110 QQ讨论群:5305909
[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
[url=http://bbs.bc-cn.net/viewthread.php?tid=162918]C++编写的Windows界面游戏[/url]
[url=http://yzfy.org/]C/C++算法习题(OnlineJudge):[/url] http://yzfy.org/
[此贴子已经被作者于2007-9-18 12:36:35编辑过]
#include <iostream>
using namespace std;int main()
{
int a;/** try on a windows machine:
input 6 7 8
and press F6 (F6 means your input is done) + enteryou will see program hangs at 8 forever
*/
while(scanf(\"%d\", &a))
{
cout<<a<<endl;if(a<=0)
break;
}return 0;
}
submitted your code at nku (sorry, without your permission)
and it runs for 340ms.
My code above runs for 220ms.
There are some code which runs for 20ms. I would think for that we need to use assembly language to do the power and multiplication.
#include<stdio.h>
int s[10001]={0};
int x=10000;
void cheng(int m)
{
int i;
for(i=10000;i>=x;i--) s[i]*=m;
for(i=10000;i>=x;i--) { s[i-1]+=s[i]/10; s[i]%=10; }
if(s[x-1]) x--;
}
int main(void)
{
int i,j,k;
int n;
s[x]=1;while( scanf(\"%d\",&n) != EOF)
{
while(n>4)
{
n-=3;
cheng(3);
}
cheng(n);
for(i=x;i<10001;i++) printf(\"%d\",s[i]);
printf(\"\n\");}
return 0;
}
遇到EOF标志你的程序就是死循环,谢谢!!!!!!!!!!!!!
by 雨中飞燕 QQ:78803110 QQ讨论群:5305909
[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
[url=http://bbs.bc-cn.net/viewthread.php?tid=162918]C++编写的Windows界面游戏[/url]
[url=http://yzfy.org/]C/C++算法习题(OnlineJudge):[/url] http://yzfy.org/