您的位置:首页 > Web前端

[2627]:Life

2016-04-09 17:49 281 查看


Problem Description

Samuel,Former Zua leader,was arrested and had to stay in prison during the Spring Festival. He was in custody for money laundering and other cases.

According to the report,Samuelwas alleged to have embezzled 104 million New Zua dollars (3.15million)inpublicfunds,acceptedbribesofabout9 million in a land purchase deal, and taken a kickback of $2.7 million from a construction project.

Although Samuel is a smart lawyer,he was still arrested due to his illegal actions.

Now Samuel has a question for you:If you are given the legislations of Zua,can you tell how many years he stay in the prison?

The legislations of Zua are supposed as the following few lines:

Input

Input will contains 3 parts. There is an integer t in the first line meaning t test cases. Then the next line has 2 parts:n(represents the cases Samuel was accused with),s(a string with the length of n,only contains “0”,”1”.Here ‘0’means he was not accused with this case,and ‘1’means he was accused with this case ) .The next n lines have the numbers of New Zua dollars(the unit is million) he was accused with.

Output

According to the law,please output how many years Samuel will stay in the prison. Use the format”Samuel was accused with m case(s),and he will stay in the prison for c year(s).”Here m means the case number,c means the years he have to stay.

Sample Input

2

3

011

10 5 15

5

01101

1 10 10 100 31

Sample Output

Samuel was accused with 2 case(s),and he will stay in the prison for 5 year(s).

Samuel was accused with 3 case(s),and he will stay in the prison for 20 year(s).

解题思路:这是一道挺简单的题目,要求对于控告的的总额进行计算,并按照相应的条例处罚(0则是没被提出控告,对应的金额不计,1对应的金额就是拿来量刑的)

#include<stdio.h>
#define N 10

int main()
{
int t;
scanf("%d", &t);
while(t--){
int num;
scanf("%d", &num);
char isAccus
;
scanf("%s", isAccus);
int accus
, i;
for(i = 0; i<num; i++){
scanf("%d", &accus[i]);
}
int sum = 0, time = 0;
for(i = 0; i<num; i++){
if(isAccus[i] == '1'){
time++;
sum += accus[i];
}
}
int level;
if(sum == 0){
level = 0;
}
if(sum > 0 && sum < 20){
level = 3;
}
if(sum > 0 && sum < 30){
level = 5;
}
if(sum >= 30 && sum < 40){
level = 10;
}
if(sum >= 40 && sum < 50){
level = 15;
}
if(sum >= 50 && sum < 60){
level = 20;
}
if(sum >= 60 && sum < 70){
level = 25;
}
if(sum >= 70 && sum < 80){
level = 30;
}
if(sum >= 80 && sum < 90){
level = 35;
}
if(sum > 90){
level = 40;
}
printf("Samuel was accused with %d case(s),and he will stay in the prison for %d year(s).\n", time, level);
}
return 0;
}




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: