Tokitsukaze and Enhancement CodeForces - 1191A
Tokitsukaze is one of the characters in the game “Kantai Collection”. In this game, every character has a common attribute — health points, shortened to HP.

In general, different values of HP are grouped into 4 categories:

Category A if HP is in the form of (4n+1), that is, when divided by 4, the remainder is 1;
Category B if HP is in the form of (4n+3), that is, when divided by 4, the remainder is 3;
Category C if HP is in the form of (4n+2), that is, when divided by 4, the remainder is 2;
Category D if HP is in the form of 4n, that is, when divided by 4, the remainder is 0.
The above-mentioned n can be any integer.

These 4 categories ordered from highest to lowest as A>B>C>D, which means category A is the highest and category D is the lowest.

While playing the game, players can increase the HP of the character. Now, Tokitsukaze wants you to increase her HP by at most 2 (that is, either by 0, 1 or 2). How much should she increase her HP so that it has the highest possible category?

Input
The only line contains a single integer x (30≤x≤100) — the value Tokitsukaze’s HP currently.

Output
Print an integer a (0≤a≤2) and an uppercase letter b (b∈{A,B,C,D}), representing that the best way is to increase her HP by a, and then the category becomes b.

Note that the output characters are case-sensitive.

Examples
Input
33
Output
0 A
Input
98
Output
1 B
Note
For the first example, the category of Tokitsukaze’s HP is already A, so you don’t need to enhance her ability.

For the second example:

If you don’t increase her HP, its value is still 98, which equals to (4×24+2), and its category is C.
If you increase her HP by 1, its value becomes 99, which equals to (4×24+3), and its category becomes B.
If you increase her HP by 2, its value becomes 100, which equals to (4×25), and its category becomes D.
Therefore, the best way is to increase her HP by 1 so that the category of her HP becomes B.
水题,尽量往等级高的地方弄就行了。
代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;int n;int main()
{while(cin>>n){if(n%4==1) cout<<"0 A"<<endl;if(n%4==2) cout<<"1 B"<<endl;if(n%4==3) cout<<"2 A"<<endl;if(n%4==0) cout<<"1 A"<<endl;}
}

Tokitsukaze and Mahjong CodeForces - 1191B
Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, we use one digit and one lowercase letter, which is the first character of the suit, to represent a suited tile. All possible suited tiles are represented as 1m, 2m, …, 9m, 1p, 2p, …, 9p, 1s, 2s, …, 9s.

In order to win the game, she must have at least one mentsu (described below) in her hand, so sometimes she should draw extra suited tiles. After drawing a tile, the number of her tiles increases by one. She can draw any tiles she wants, including those already in her hand.

Do you know the minimum number of extra suited tiles she needs to draw so that she can win?

Here are some useful definitions in this game:

A mentsu, also known as meld, is formed by a koutsu or a shuntsu;
A koutsu, also known as triplet, is made of three identical tiles, such as [1m, 1m, 1m], however, [1m, 1p, 1s] or [1m, 4m, 7m] is NOT a koutsu;
A shuntsu, also known as sequence, is made of three sequential numbered tiles in the same suit, such as [1m, 2m, 3m] and [5s, 7s, 6s], however, [9m, 1m, 2m] or [1m, 2p, 3s] is NOT a shuntsu.
Some examples:

[2m, 3p, 2s, 4m, 1s, 2s, 4s] — it contains no koutsu or shuntsu, so it includes no mentsu;
[4s, 3m, 3p, 4s, 5p, 4s, 5p] — it contains a koutsu, [4s, 4s, 4s], but no shuntsu, so it includes a mentsu;
[5p, 5s, 9m, 4p, 1s, 7p, 7m, 6p] — it contains no koutsu but a shuntsu, [5p, 4p, 6p] or [5p, 7p, 6p], so it includes a mentsu.
Note that the order of tiles is unnecessary and you can assume the number of each type of suited tiles she can draw is infinite.

Input
The only line contains three strings — the tiles in Tokitsukaze’s hand. For each string, the first character is a digit ranged from 1 to 9 and the second character is m, p or s.

Output
Print a single integer — the minimum number of extra suited tiles she needs to draw.

Examples
Input
1s 2s 3s
Output
0
Input
9m 9m 9m
Output
0
Input
3p 9m 2p
Output
1
Note
In the first example, Tokitsukaze already has a shuntsu.

In the second example, Tokitsukaze already has a koutsu.

In the third example, Tokitsukaze can get a shuntsu by drawing one suited tile — 1p or 4p. The resulting tiles will be [3p, 9m, 2p, 1p] or [3p, 9m, 2p, 4p].
跟打麻将差不多吧。要把最后结果弄成同花顺,三个数相同,问应该操作多少步。
代码如下:

#include<bits/stdc++.h>
using namespace std;const int maxx=1e2+10;
string s;
int a[maxx],b[maxx],c[maxx];int main()
{memset(a,0,sizeof(a));memset(b,0,sizeof(b));memset(c,0,sizeof(c));for(int i=0;i<3;i++){cin>>s;if(s[1]=='s') a[s[0]-'0']++;if(s[1]=='m') b[s[0]-'0']++;if(s[1]=='p') c[s[0]-'0']++;}int flag1=0;int flag2=0;for(int i=1;i<10;i++){if(a[i]==3||b[i]==3||c[i]==3) flag1=1;if(a[i]==2||b[i]==2||c[i]==2) flag2=1;}for(int i=1;i<10;i++){if(a[i]&&a[i+1]&&a[i+2]) flag1=1;if(b[i]&&b[i+1]&&b[i+2]) flag1=1;if(c[i]&&c[i+1]&&c[i+2]) flag1=1;if(a[i]&&a[i+1]) flag2=1;if(a[i]&&a[i+2]) flag2=1;if(b[i]&&b[i+1]) flag2=1;if(b[i]&&b[i+2]) flag2=1;if(c[i]&&c[i+1]) flag2=1;if(c[i]&&c[i+2]) flag2=1;}if(flag1) puts("0");else if(flag2) puts("1");else puts("2");return 0;
}

Tokitsukaze and Discard Items CodeForces - 1191C
Recently, Tokitsukaze found an interesting game. Tokitsukaze had n items at the beginning of this game. However, she thought there were too many items, so now she wants to discard m (1≤m≤n) special items of them.

These n items are marked with indices from 1 to n. In the beginning, the item with index i is placed on the i-th position. Items are divided into several pages orderly, such that each page contains exactly k positions and the last positions on the last page may be left empty.

Tokitsukaze would do the following operation: focus on the first special page that contains at least one special item, and at one time, Tokitsukaze would discard all special items on this page. After an item is discarded or moved, its old position would be empty, and then the item below it, if exists, would move up to this empty position. The movement may bring many items forward and even into previous pages, so Tokitsukaze would keep waiting until all the items stop moving, and then do the operation (i.e. check the special page and discard the special items) repeatedly until there is no item need to be discarded.

Consider the first example from the statement: n=10, m=4, k=5, p=[3,5,7,10]. The are two pages. Initially, the first page is special (since it is the first page containing a special item). So Tokitsukaze discards the special items with indices 3 and 5. After, the first page remains to be special. It contains [1,2,4,6,7], Tokitsukaze discards the special item with index 7. After, the second page is special (since it is the first page containing a special item). It contains [9,10], Tokitsukaze discards the special item with index 10.
Tokitsukaze wants to know the number of operations she would do in total.

Input
The first line contains three integers n, m and k (1≤n≤1018, 1≤m≤105, 1≤m,k≤n) — the number of items, the number of special items to be discarded and the number of positions in each page.

The second line contains m distinct integers p1,p2,…,pm (1≤p1<p2<…<pm≤n) — the indices of special items which should be discarded.

Output
Print a single integer — the number of operations that Tokitsukaze would do in total.

Examples
Input
10 4 5
3 5 7 10
Output
3
Input
13 4 5
7 8 9 10
Output
1
Note
For the first example:

In the first operation, Tokitsukaze would focus on the first page [1,2,3,4,5] and discard items with indices 3 and 5;
In the second operation, Tokitsukaze would focus on the first page [1,2,4,6,7] and discard item with index 7;
In the third operation, Tokitsukaze would focus on the second page [9,10] and discard item with index 10.
For the second example, Tokitsukaze would focus on the second page [6,7,8,9,10] and discard all special items at once.
一个序列,分成几页,每页都有k个数,现在要移除一些数。每一次移除处在相同页上的数字,问要操作几次。
一个模拟,没有什么技巧。记录移动的步数,处在相同页上的数字,除以k之后是相等的。
代码如下:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#define ll long long
using namespace std;const int maxx=1e5+100;
ll a[maxx];
ll n,m,k;int main()
{while(scanf("%lld%lld%lld",&n,&m,&k)!=EOF){for(int i=1;i<=m;i++) cin>>a[i];ll ans=0;ll move=0;ll x=k;for(int i=1;i<=m;){int j=i;while((a[j]-move-1)/k==(a[i]-move-1)/k) j++;ans++;move+=j-i;i=j;}printf("%lld\n",ans);}
}

Tokitsukaze, CSL and Stone Game CodeForces - 1191D
Tokitsukaze and CSL are playing a little game of stones.

In the beginning, there are n piles of stones, the i-th pile of which has ai stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a nonempty pile and removes exactly one stone from the pile. A player loses if all of the piles are empty before his turn, or if after removing the stone, two piles (possibly empty) contain the same number of stones. Supposing that both players play optimally, who will win the game?

Consider an example: n=3 and sizes of piles are a1=2, a2=3, a3=0. It is impossible to choose the empty pile, so Tokitsukaze has two choices: the first and the second piles. If she chooses the first pile then the state will be [1,3,0] and it is a good move. But if she chooses the second pile then the state will be [2,2,0] and she immediately loses. So the only good move for her is to choose the first pile.

Supposing that both players always take their best moves and never make mistakes, who will win the game?

Note that even if there are two piles with the same number of stones at the beginning, Tokitsukaze may still be able to make a valid first move. It is only necessary that there are no two piles with the same number of stones after she moves.

Input
The first line contains a single integer n (1≤n≤105) — the number of piles.

The second line contains n integers a1,a2,…,an (0≤a1,a2,…,an≤109), which mean the i-th pile has ai stones.

Output
Print “sjfnb” (without quotes) if Tokitsukaze will win, or “cslnb” (without quotes) if CSL will win. Note the output characters are case-sensitive.

Examples
Input
1
0
Output
cslnb
Input
2
1 0
Output
cslnb
Input
2
2 2
Output
sjfnb
Input
3
2 3 1
Output
sjfnb
Note
In the first example, Tokitsukaze cannot take any stone, so CSL will win.

In the second example, Tokitsukaze can only take a stone from the first pile, and then, even though they have no stone, these two piles will have the same number of stones, which implies CSL will win.

In the third example, Tokitsukaze will win. Here is one of the optimal ways:

Firstly, Tokitsukaze can choose the first pile and take a stone from that pile.
Then, CSL can only choose the first pile, because if he chooses the second pile, he will lose immediately.
Finally, Tokitsukaze can choose the second pile, and then CSL will have no choice but to lose.
In the fourth example, they only have one good choice at any time, so Tokitsukaze can make the game lasting as long as possible and finally win.
一个博弈论。n堆石子,两个人每次拿一个,如果拿完之后出现两堆石子数相等或者没有石子可以拿了,就输了。问谁会赢。
先来分析先手必败的情况:
①有三堆或以上石子数目相同。
②有两堆或以上石子数目为零。
③有两堆石子数目相同,这样的有多个。例如 3 3 4 4 7。
④有两堆石子数目相同,而且还有一堆石子的数目比它少一。例如 4 5 5。
除去这些情况,就是俩个人公平竞争大的时候了。
先来分析一下必败态,就是0,1,2,3,,,,n-1。谁遇到这样的情况,谁肯定就输了。那么每个人拿一个石头,谁会遇到这种情况呢。分析(sum-n*(n-1)/2)的奇偶性就可以了。
代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;const int maxx=1e5+100;
int a[maxx];
int n;bool check()
{int cnt=0;if(n==1&&a[1]==0) return 1;for(int i=1;i<=n;i++){if(a[i]==0) cnt++;}if(cnt>=2) return 1;for(int i=1;i<=n-2;i++){if(a[i]==a[i+1]&&a[i+1]==a[i+2]) return 1;}cnt=0;a[0]=-1;for(int i=1;i<=n-1;i++){if(a[i]==a[i+1]) {cnt++;if(a[i]-a[i-1]==1) return 1;}}if(cnt>1) return 1;return 0;
}
int main()
{while(scanf("%d",&n)!=EOF){for(int i=1;i<=n;i++) scanf("%d",&a[i]);sort(a+1,a+1+n);if(check()){puts("cslnb");}else{ll sum=0;for(int i=1;i<=n;i++) sum+=a[i];if((sum-n*(n-1)/2)&1) puts("sjfnb");else puts("cslnb");}}return 0;
}

后两道题没出来,嘤嘤嘤
努力加油a啊,(o)/~

Codeforces Round #573 (Div. 2)(ABCD)相关推荐

  1. Codeforces Round #249 (Div. 2) (模拟)

    Codeforces Round #249 (Div. 2) (模拟) C. Cardiogram time limit per test 1 second memory limit per test ...

  2. Codeforces Round #791 (Div. 2)(A-D)

    Codeforces Round #791 (Div. 2)(A-D) A. AvtoBus 题意: 给你 n, 问满足 4x+6y=n4x+6y=n4x+6y=n 的 x+yx+yx+y的最小值和最 ...

  3. Codeforces Round #613 (Div. 2)(B-D)

    Codeforces Round #613 (Div. 2) B -抢时间&手感生疏->(第n + 1次)被long long卡掉- C 又一次败给了常识-EC的M题也是一个关于素数的暴 ...

  4. Codeforces Round #736 (Div. 2)(B-C)

    Codeforces Round #736 (Div. 2) 花了十分钟帮朋友写了B,C就睡觉了,自己没打 B 先看上,再看左后看右 #include <iostream> #includ ...

  5. Codeforces Round #735 (Div. 2)(A-D)没有B

    Codeforces Round #735 (Div. 2) A 一道小思维题 #include <bits/stdc++.h> using namespace std; #define ...

  6. Codeforces Round #644 (Div. 3)(A-E)

    这场的A-E都是水题,就简单记录一下吧. Minimal Square CodeForces - 1360A 思路:我们令b=max(a,b),a=min(a,b). 如果b>=2*a的话,最终 ...

  7. Codeforces Round #572 (Div. 2)(ABCD1D2E)

    Keanu Reeves CodeForces - 1189A After playing Neo in the legendary "Matrix" trilogy, Keanu ...

  8. Codeforces Round #640 (Div. 4)(ABCDE)

    Sum of Round Numbers CodeForces - 1352A 思路:按照题意模拟即可. 代码如下: #include<bits/stdc++.h> #define ll ...

  9. Codeforces Round #731 (Div. 3)(ABCDEFG)

    A. Shortest Path with Obstacle 当两个点的x坐标或者y坐标相同的时候,需要多花2费绕开 #include<bits/stdc++.h> using names ...

最新文章

  1. vue 设置输入法隐藏_原来iPhone自带的输入法这么强大?好多人都不知道其中的隐藏功能...
  2. BAT面试题9:谈谈判别式模型和生成式模型?
  3. Drools解决积分问题
  4. 30天python开发_30天解锁Python量化开发——初探交易接口
  5. 开始→运行→命令集锦
  6. Windows进程与线程学习笔记(八)—— 线程切换与TSS/FS
  7. Ubuntu环境下安装Bochs
  8. 提示用户输入一个正整数n,如果n=5,就输出下列图形,其他n值以此类推
  9. cpu system linux,LINUX system BOOT
  10. 微软ping程序源代码完整版(附详细的注释)
  11. oracle数据库无法查询,关于oracle中无法查询中文条件的解决办法
  12. 太仓爱尚你婚庆--太仓浪漫婚庆第一品牌
  13. 多项目加载顺序修改_面试官:Java 类在 Tomcat 中是如何加载的?
  14. AR/MR技术的应用
  15. 蓝桥杯题目练习(摆动序列)
  16. 好用的在线开发辅助工具
  17. VFP 常用 OCX 控件 注册
  18. 什么是数据库?什么是数据库管理系统? 说明两者的区别和联系。
  19. 2017年3月14日-----------乱码新手自学.net 之Authorize特性与Forms身份验证(登陆验证、授权小实例)...
  20. matlab编写多目标测试函数SCH, ZDT, MOP, DTLZ

热门文章

  1. 已知序列求蝶形运算_(数字信号处理选择题.doc
  2. rpm如何卸载mysql_Linux下卸载和安装MySQL[rpm包]
  3. kali Linux 基础
  4. 如何知道交换机的缓存大小_网络基本功之细说交换机
  5. imagecomposition工程分析
  6. java 单开程序_java生成jar包并且单进程运行的实例
  7. 鸿蒙OS手机版正式发布,鸿蒙OS前三批升级名单曝光,华为荣耀手机均可升级,幸福来得太突然...
  8. 如何手写代码进行页面布局
  9. 盘点2010年十大出版事件 文著协“宣战”百度文库
  10. ELK安装配置及nginx日志分析