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.
**题意:**游戏中,一个整数HP,表示生命值。
定义A等级,则HP%41
定义B等级,则HP%4
3
定义C等级,则HP%42
定义D等级,则HP%4
0
同时定义等级A>等级B>等级C>等级D
现在可以加0或1或2点HP,使得等级尽可能高。
输入一个整数表示HP 输出最优时应加的HP点数和最后的等级。
**思路:**就是数学题,在一个范围内求四的余数。
代码:#include <stdio.h>
int main(){
int x;
char y;
scanf ("%d",&x);
x%=4;
switch(x)
{
case 0:{x=1;y=‘A’;
break;
}
case 1:{x=0;y=‘A’;
break;
}
case 2:{x=1;y=‘B’;
break;
}
case 3:{x=2;y=‘A’;
break;
}
}
printf("%d %c",x,y);

return 0;
}
**总结:**水题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值