|
|
вернуться в форумFor those who got WA on test#2 Послано xcheng 27 авг 2007 07:30 if n=1 the answer a=0 p=2 is wrong! The correct answer is a=1 p=1
Re: For those who got WA on test#2 Answer 1 1, but WA2 #include<iostream> #include<cmath> using namespace std; int main() { int n; int a; int p; int x,y; int i,j; int result=0; cin>>n; a=sqrt((float)n)+1; p=a; x=y=0; for (i=1;i<=a;i++) { result=0; for (j=1;j<=p;j++) { result+=(i+(j-1)); if (result==n) { if (y<j) { x=i; y=j; } } } } cout<<x<<" "<<y<<endl; return 0; } |
|
|