Codeforces Round #573 (Div. 2) A. Tokitsukaze and Enhancement

Codeforces Round #573 (Div. 2)

A. Tokitsukaze and Enhancement

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.

题意:题目意思是给一个数根据mod 4 的四个结果定义等级,余1等级A,余3等级B,余2等级C,余0等级D。

 问给你一个数,你可以对数加a:0<=a<=2,问这个数能提升到的最高等级和对应的a。

思路:直接讨论四种情况的最优解就好了,例如n mod 4 = 3 时,显然加2就变成 余1为等级A了......

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<map>
 6 #include<set>
 7 #include<vector>
 8 #include<queue>
 9 #include<cmath>
10 using namespace std;
11 #define ll long long
12 const int mod=1e9+7;
13 const int inf=1e9+7;
14
15 //const int maxn=
16 int main()
17 {
18     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
19     int n;
20     while(cin>>n)
21     {
22         if(n%4==1)
23             cout<<0<<" "<<"A"<<endl;
24         else if(n%4==2)
25             cout<<1<<" "<<"B"<<endl;
26         else if(n%4==3)
27             cout<<2<<" "<<"A"<<endl;
28         else if(n%4==0)
29             cout<<1<<" "<<"A"<<endl;
30     }
31     return 0;
32 }

原文地址:https://www.cnblogs.com/xwl3109377858/p/11182079.html

时间: 2024-10-30 05:20:42

Codeforces Round #573 (Div. 2) A. Tokitsukaze and Enhancement的相关文章

Codeforces Round #573 (Div. 2) E. Tokitsukaze and Duel (博弈)

time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output "Duel!" Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started. There are n cards in a row. Each card h

Codeforces Round #573 (Div. 2).A

A - Tokitsukaze and Enhancement 题目链接:http://codeforces.com/contest/1191/problem/A 题目: 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

Codeforces Round #573 (Div. 2)

D. Tokitsukaze, CSL and Stone Game 题意:有n堆石头,每人每次只能去一颗石子,若轮到当前人没任何一堆石子可以取或当前人取到后剩下有俩堆石子个数相同则当前人输: 给定石子序列. 分析:1.若有类似“2 3 3 ”则后手胜,因为有这个序列就必须在这个序列中去石子(因为如果在这个序列以外取子,则会导致输的后者情况),但在这个序列中取不到可解情况,所以该状态为必败态: 2.若序列中有俩对相同的石子,则后手胜: 3.除1.2情况外就把利用sum+起来,每个加就+a[i]-

Codeforces Round #573 (Div. 2) A B C

ATokitsukaze and Enhancement #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+100; int x; int main(){ cin >> x; int cnt = 0; if( x%4 <= 1 || x%4==3){ if (x%4==0) cnt=1; if(x%4 ==3) cnt=2; cout << cnt

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i

Codeforces Round #424 (Div. 2) D. Office Keys(dp)

题目链接:Codeforces Round #424 (Div. 2) D. Office Keys 题意: 在一条轴上有n个人,和m个钥匙,门在s位置. 现在每个人走单位距离需要单位时间. 每个钥匙只能被一个人拿. 求全部的人拿到钥匙并且走到门的最短时间. 题解: 显然没有交叉的情况,因为如果交叉的话可能不是最优解. 然后考虑dp[i][j]表示第i个人拿了第j把钥匙,然后 dp[i][j]=max(val(i,j),min(dp[i-1][i-1~j]))   val(i,j)表示第i个人拿

Codeforces Round #424 (Div. 2) C. Jury Marks(乱搞)

题目链接:Codeforces Round #424 (Div. 2) C. Jury Marks 题意: 给你一个有n个数序列,现在让你确定一个x,使得x通过挨着加这个序列的每一个数能出现所有给出的k个数. 问合法的x有多少个.题目保证这k个数完全不同. 题解: 显然,要将这n个数求一下前缀和,并且排一下序,这样,能出现的数就可以表示为x+a,x+b,x+c了. 这里 x+a,x+b,x+c是递增的.这里我把这个序列叫做A序列 然后对于给出的k个数,我们也排一下序,这里我把它叫做B序列,如果我

[Codeforces] Round #352 (Div. 2)

人生不止眼前的狗血,还有远方的狗带 A题B题一如既往的丝帛题 A题题意:询问按照12345678910111213...的顺序排列下去第n(n<=10^3)个数是多少 题解:打表,输出 1 #include<bits/stdc++.h> 2 using namespace std; 3 int dig[10],A[1005]; 4 int main(){ 5 int aa=0; 6 for(int i=1;;i++){ 7 int x=i,dd=0; 8 while(x)dig[++dd

Codeforces Round #273 (Div. 2)

Codeforces Round #273 (Div. 2) 题目链接 A:签到,仅仅要推断总和是不是5的倍数就可以,注意推断0的情况 B:最大值的情况是每一个集合先放1个,剩下都丢到一个集合去,最小值是尽量平均去分 C:假如3种球从小到大是a, b, c,那么假设(a + b) 2 <= c这个比較明显答案就是a + b了.由于c肯定要剩余了,假设(a + b)2 > c的话,就肯定能构造出最优的(a + b + c) / 3,由于肯定能够先拿a和b去消除c,而且控制a和b成2倍关系或者消除