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

too watery, why so few people ACed?

Posted by KatrineYang at 2016-09-13 10:43:37 on Problem 1303
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int toInt(char *s){
	int ret = 0;
	int len = strlen(s);
	for(int i = 0; i < len; i++){
		ret *= 2;
		ret += s[i]-'0';
	}
	return ret;
}

int main() {
	char fei[16];
	int p;
	while(1){
		scanf("%s", fei);
		if(strcmp(fei, "ENDOFINPUT") == 0) break;
		scanf("%d", &p);
		printf("HAND %d\n", p);
		char temp[10];
		scanf("%s", temp);
		int i1 = toInt(temp);
		scanf("%s", temp);
		int i2 = toInt(temp);
		int mx = 0;
		for(int i = 0; i < p; i++){
			scanf("%s", temp);
			int ii = toInt(temp);
			if(ii > mx) mx = ii;
		}
		int bVal[4], nVal[4];
		for(int i = 0; i < 4; i++){
			scanf("%s", temp);
			bVal[i] = toInt(temp);
		}
		for(int i = 0; i < 4; i++){
			scanf("%s", temp);
			nVal[i] = toInt(temp);
		}
		scanf("%s", fei);
		int bOffset = 0, nOffset = 0, cs = 0, fs = i1+i2;
		mx += 255;
		while(1){
			if(fs >= mx || cs == 4 || fs > 500) break;
			if(fs < 382){
				fs += bVal[bOffset];
				bOffset++;
				cs++;
				printf("Byte me!\n");
			}
			else{
				fs += nVal[nOffset];
				nOffset++;
				cs++;
				printf("Nibble me!\n");
			}
		}
		if(fs > 510){
			printf("Bust!\n");
		}
		else if(fs >= mx){
			printf("Win!\n");
		}
		else{
			printf("Lose!\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