| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:哪位大牛帮忙看一下程序,实在是不知道哪里错了In Reply To:哪位大牛帮忙看一下程序,实在是不知道哪里错了 Posted by:alpc05 at 2006-08-07 13:12:10 > #include<stdio.h>
>
> __int64 m;
> int n,a[100],b[100];
>
> main(){
> char x[100];
> int tt,test,i,j;
> scanf("%d",&test);
> for (tt=1;tt<=test;tt++) {
> scanf("%d",&n);
> if (n>0) scanf("%s",x);
> for (i=n-1;i>=0;i--) {
> if (x[i]=='p') a[n-1-i]=1;
> else a[n-1-i]=-1;
> }
> scanf("%I64d",&m);
> for (i=0;i<n;i++)
> if (m%2!=0) {
> m=(m-a[i])/2;
> b[i]=1;
> }
> else {
> b[i]=0;
> m=m/2;
> }
> if (m!=0) printf("Impossible\n");
> else {
> j=n-1;
> while (j>0 && b[j]==0) j--;
> for (i=j;i>=0;i--)
> printf("%d",b[i]);
> printf("\n");
> }
> }
> return 0;
> }
去掉这句话
while (j>0 && b[j]==0) j--;
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator