|
|
вернуться в форумwrong answer test #15 can anyone tell me whats wrong with my code. it displays wrong answer test #15 #include<iostream> #include<string.h> using namespace std; int main() { long int n; long int ans=1; char k[20]; cin>>n>>k; if(n<1||n>10) return 0; long int res; res=n%strlen(k); long int i=0,length=strlen(k); if(length<1||length>20) return 0;
if(res==0) { while(n-i*length>=length) { ans=ans*(n-i*length); i++; } } else { while(n>=i*length) { ans=ans*(n-i*length); i++; } } cout<<ans; return 0; } Edited by author 21.08.2010 11:32 Re: wrong answer test #15 15 test n=10 k=20 it's last test Re: wrong answer test #15 > char k[20] You forgot about the null character ( '\0' ). Correct is char k[21] |
|
|