Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位大牛帮忙看一下程序,实在是不知道哪里错了

Posted by alpc05 at 2006-08-07 13:12:10 on Problem 1023
#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;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator