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

偶在ZJU过了, 为什么在这儿WA?

Posted by hacky at 2004-12-24 00:46:14 on Problem 1023
这里G++不支持long long int么?

#include <cstdio>

int main() {
	int t,i,j,k,sign,pos;
	char pn[64],num[64];
	long long int N;
	scanf("%d\n", &t);
	for (i=0; i<t; i++) {
		scanf("%d\n", &k);
		scanf("%s\n", pn);
		scanf("%lld\n", &N);
		pos=0;
		if (N>0) sign=1; else sign=-1;
		for (j=k-1; j>=0; j--) {
			if (pn[j]=='p') {
				num[pos]=sign*(N%2);
				N = (N-num[pos])/2;
				pos++;
			} else {
				num[pos]=sign*(N%2);
				N = (N+num[pos])/2;
				pos++;
			}
		}
		if (N!=0) {printf("Impossible\n"); continue;}
		for (j=pos-1; j>=0; j--) {
			printf("%d",num[j]);
		}
		printf("\n");
	}
}

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