fzu 2146 Easy Game & 2147 A-B Game & 2151 OOXX Game(水题)

30 篇文章 0 订阅

题目链接:fzu 2146 Easy Game 

题目连接:fzu 2147 A-B Game

题目链接:fzu 2151 OOXX Game


题意略。


2146

#include <stdio.h>
#include <string.h>

const int N = 10100;
const char sign[2][N] = {"Even", "Odd"};

int main () {
	char str[N];
	int cas;
	scanf("%d", &cas);
	for (int i = 1; i <= cas; i++) {
		scanf("%s", str);
		int len = strlen(str);
		printf("Case %d: %s\n", i, sign[len % 2]);
	}
	return 0;
}


2147

解题思路:每次最多减(A - 1)/2.

#include <stdio.h>
#include <string.h>
#include <iostream>

using namespace std;

typedef long long ll;
ll A, B;

int solve() {
	int ans = 0;
	while (A > B) {
		A = A - (A - 1) / 2;
		ans++;
	}
	return ans;
}

int main() {
	int cas;
	scanf("%d", &cas);
	for (int i = 1; i <= cas; i++) {
		cin >> A >> B;
		printf("Case %d: %d\n", i, solve());
	}
	return 0;
}


2151

#include <stdio.h>
#include <string.h>

const int N = 105;
const char sign[2][N] = {"Fat brother", "Maze"};

int main () {
	int cas, l, r;
	char str[N];
	scanf("%d", &cas);
	for (int i = 1; i <= cas; i++) {
		int ans = 0;
		scanf("%d%d", &r, &l);
		for (int j = 0; j < r; j++) {
			scanf("%s", str);
			for (int k = 0; k < l; k++) if (str[k] == 'O') ans++;
		}	
		printf("Case %d: %s\n", i, sign[ans % 2]);

	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值