There is a lot of math involved here. Here is my attack, which
is accepted at http://acm.nankai.edu.cn/p1002.html
To compete for smaller source file size, I rewrote it as a .c file (accepted of course and but with no readability).
I don't know why the online judge said that my program needs 672kb memory while other people are using
just 32kb. Frankly, I don't think the following one line source code will need 672kb memory.
What is wrong here?
int main(){int n;while(scanf(\"%d\",&n)!=-1){while(n<50025002)n+=2000;printf(\"%d\n\",n-5);}return 0;}
===============================================================
(.cpp file)
#include <iostream>
using namespace std;
int f(int a, int b, int N, int n)
{
int temp = a - b;
while(n<N)
{
n+=temp;
}
return n-b;
}
int main()
{
int n;
while ( scanf("%d", &n) != EOF )
{
printf("%d\n", f(2005, 5, 50025002, n));
}
return 0;
}
[此贴子已经被作者于2007-7-18 7:16:36编辑过]