题目网址
**题目:**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%43
定义C等级,则HP%42
定义D等级,则HP%40
同时定义等级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;
}
**总结:**水题。