2017-4-14:Train-第四届福建省赛

G - Easy Game(水题)

Fat brother and Maze are playing a kind of special (hentai) game on a string S. Now they would like to count the length of this string. But as both Fat brother and Maze are programmers, they can recognize only two numbers 0 and 1. So instead of judging the length of this string, they decide to judge weather this number is even.

Input

The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case contains a line describe the string S in the treasure map. Not that S only contains lower case letters.

1 <= T <= 100, the length of the string is less than 10086

Output

For each case, output the case number first, and then output “Odd” if the length of S is odd, otherwise just output “Even”.

Sample Input

4

well

thisisthesimplest

problem

inthiscontest

Sample Output

Case 1: Even

Case 2: Odd

Case 3: Odd

Case 4: Odd

Means:

给你一串字符,问你这串字符的长度是奇数还是偶数

Solve:

一个水题,不是吗

Code:

 1 #include <cstdio>
 2 #include <cstring>
 3 using namespace std;
 4 #define CLR(x , v)        memset(x , v , sizeof(x))
 5 #define CASE(x)            printf("Case %d: " , x)
 6 static const int MAXN = 10086;
 7 char data[MAXN];
 8 int main()
 9 {
10     int t;
11     scanf("%d" , &t);
12     for(int c = 1 ; c <= t ; ++c)
13     {
14         CLR(data , ‘\0‘);
15         scanf(" %s" , data);
16         int len = strlen(data);
17         CASE(c);
18         if(len & 1)
19             printf("Odd\n");
20         else
21             printf("Even\n");
22     }
23 }

H - A-B Game(数学,贪心)

Fat brother and Maze are playing a kind of special (hentai) game by two integers A and B. First Fat brother write an integer A on a white paper and then Maze start to change this integer. Every time Maze can select an integer x between 1 and A-1 then change A into A-(A%x). The game ends when this integer is less than or equals to B. Here is the problem, at least how many times Maze needs to perform to end this special (hentai) game.

Input

The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case contains two integers A and B described above.

1 <= T <=100, 2 <= B < A < 100861008610086

Output

For each case, output the case number first, and then output an integer describes the number of times Maze needs to perform. See the sample input and output for more details.

Sample Input

2

5 3

10086 110

Sample Output

Case 1: 1

Case 2: 7

Means:

给你一个数A,一个数B,问你最少经过多少次可以使得A小于等于B,A的操作为A - (A % x) , 其中x为[1 , A - 1]的任意一个数。

Solve:

贪心,每次取X最大,那么什么时候X最大,当X = A / 2 + 1的时候,因为A/2的话,偶数就GG了,然后就能保证每次A减去的就是最大的,剩下的A就是A/2 + 1

Code:

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <iostream>
 4 using namespace std;
 5 #define CLR(x , v)        memset(x , v , sizeof(x))
 6 #define CASE(x)            printf("Case %d: " , x)
 7 typedef unsigned long long LL;
 8 int t;
 9 LL a , b;
10 int main()
11 {
12     scanf("%d" , &t);
13     for(int c = 1 ; c <= t ; ++c)
14     {
15         LL ans = 0;
16         scanf("%lld%lld" , &a , &b);
17         while(a > b)
18         {
19             a = a >> 1 | 1;
20             ++ans;
21         }
22         CASE(c);
23         printf("%d\n" , ans);
24     }
25 }

时间: 2024-10-06 00:45:10

2017-4-14:Train-第四届福建省赛的相关文章

Sdut 2108 Alice and Bob(数学题)(山东省ACM第四届省赛D题)

题目地址:sdut 2608 Alice and Bob Alice and Bob Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynomial like this: (a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*....

51CTO论坛搜索升级,支持模糊查询 2017.6.14

51CTO论坛搜索进行升级,使用新搜索算法,支持模糊查询,更容易查找到相关帖子.目前的结果切换到so.51cto.com,欢迎大家体验.在论坛首页顶部搜索框搜索已经支持最新搜索技术,后续会在版块页.帖子页的搜索也使用新搜索技术.2017.6.14 过去的论坛搜索,是在论坛数据库搜索,一方面搜索需要等待时间长,点击一次才能进入,另一方面搜索不支持模糊查询,经常找不到搜索结果. 这次搜索的升级切换,也依然可能有问题,欢迎大家留言说说自己的体验和问题,后面我们还会继续优化搜索算法,提升搜索体验.

2017年ICPC中国大陆区域赛真题(下)

2017年ICPC中国大陆区域赛真题(下) A - Lovers #include <bits/stdc++.h> using namespace std; const int maxn=2e5+10; int n,k,a[maxn],b[maxn],ans; int main() { int _; scanf("%d", &_); while (_--) { scanf("%d%d", &n, &k); for (int i =

2017.07.14【NOIP提高组】模拟赛B组

Summary 这次比赛因为迟到了,少了很多时间,也受到了相应的惩罚,这是好的,是个标记牌,警醒着我.这次比赛的题目很难,也就是说,大家的得分都很低,总的来说,收获还是很大的,因为有非常多的技巧被掌握了.我对细节的处理不足,这几天的比赛都是这样,每天弄到很晚结果就是一个小小的细节. Problem T1 最大公约数 题目大意 让你求

2017福建省赛 FZU2272~2283

1.FZU2272 Frog 传送门:http://acm.fzu.edu.cn/problem.php?pid=2272 题意:鸡兔同笼通解 题解:解一个方程组直接输出就行 代码如下: #include <map> #include <set> #include <cmath> #include <ctime> #include <stack> #include <queue> #include <cstdio> #in

2017.9.17校内noip模拟赛解题报告

预计分数:100+60+60=220 实际分数:100+60+40=200 除了暴力什么都不会的我..... T1 2017.9.17巧克力棒(chocolate) 巧克力棒(chocolate)Time Limit:1000ms Memory Limit:64MB题目描述LYK 找到了一根巧克力棒,但是这根巧克力棒太长了,LYK 无法一口吞进去.具体地,这根巧克力棒长为 n,它想将这根巧克力棒折成 n 段长为 1 的巧克力棒,然后慢慢享用.它打算每次将一根长为 k 的巧克力棒折成两段长为 a

2017后期 第 1 场训练赛

题目依次为 NKOJ 上 P3496 P4236 P3774 P2407 1.数三角形 方法很多, 比如推出三边 x y z 的限制关系, 然后加加减减得到计算式子 不过也可以用观察法, 暴力计算出 n 为 1 至 13 对应的结果为: 0 0 0 1 3 7 13 22 34 50 70 95 125 相邻两数差为: 0 0 1 2 4 6 9 12 16 20 25 30 这些相邻两数相邻差又为: 0 1 1 2 2 3 3 4 4 5 5 找到规律了, 如果结果第 i 项为第 i - 1

[2017.3.14]代码穿梭机 王者荣耀

1 #include<cmath> 2 #include<queue> 3 #include<cstdio> 4 #include<vector> 5 #include<cstdlib> 6 #include<cstring> 7 #include<iostream> 8 #include<algorithm> 9 #define N 10000010 10 #define RG register 11 #de

2015福建省赛

 Problem A Super Mobile Charger Accept: 217    Submit: 402 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description While HIT ACM Group finished their contest in Shanghai and is heading back Harbin, their train was delayed due to the hea