|
|
вернуться в форумWA #2 //WHY #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; int main(){ int n=0; //scanf("%d",&n); char c[25]; //scanf("%c",c); int p=0; gets(c);//printf("%c",c[0]); int x=0,y; if(c[1]==' '){y=2;n=c[0]-48;} else {y=3;n=10;}
int l=strlen(c); for(x=y;x<l;x++)if(c[x]==c[y])p++; int ans=1; while(n>=(n+p)%p){ans*=n;n-=p;} printf("%d",ans); // system("pause"); return 0; } Re: WA #2 //Accepted #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; int main(){ int n=0; //scanf("%d",&n); char c[25]; //scanf("%c",c); int p=0; gets(c);//printf("%c",c[0]); int x=0,y; if(c[1]==' '){y=2;n=c[0]-48;} else {y=3;n=10;}
int l=strlen(c); for(x=y;x<l;x++)if(c[x]==c[y])p++; int ans=1; while(n>=(n+p)%p&&n>0){ans*=n;n-=p;} printf("%d",ans); // system("pause"); return 0; } |
|
|