|
|
вернуться в форумWA test 10 Послано Rustam 8 июн 2007 19:56 I can't understand why wrong answer in test 10 here is my code #include <iostream> using namespace std; int main() { long int i=2,j,k,n,s=1; char a[100]; cin>>n; cin>>a; k=strlen(a); if(n%k) { j=n-k; s=n; while(j>=(n%k)) { s*=j; j=n-(i++)*k; } s*=n%k; } if(n%k==0) { j=n-k; s=n; while(j) { s*=j; j=n-(i++)*k; } } if(n<=k) s=n; return 0; } Use Greater Data Type use unsigned __int64: My AC Code,Neat:) #include<iostream> #include<string> using namespace std; int main (void){ int n,k; string s; cin>>n>>s; k=s.size(); unsigned __int64 fac=1; while (n>0){ fac*=n; n-=k; } cout<<fac<<endl; return 0; } Edited by author 13.07.2009 19:48 Edited by author 13.07.2009 19:48 Edited by author 13.07.2009 19:48 Edited by author 13.07.2009 19:48 |
|
|