[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; }
相关文章推荐
- hdu 4715 Difference Between Primes【筛法快速求素数表+思维】
- React:纯属性(pure prop),受控属性(controlled prop),半受控属性(half-controlled prop),一次性属性(onetime-prop)
- Java中的WeakReference讲解
- HTML常见标签学习和笔记总结
- Preference Learning——Introduction
- 安卓 json解析如何使用与讲解
- HTML中div垂直居中的三种方式
- a 标签中调用js的几种方法
- js confirm()方法的使用方法实例
- 用VS2013搭建前端开发环境的心得
- JSTL标签用法
- JavaScript里的类和继承
- CSS3实例教程:详解calc()函数功能
- 隐藏(删除) Preference 小结
- 优就业JS教程-JavaScript创建对象4种方法详解
- 16链表的反转|剑指offer
- [BZOJ 1012][JSOI2008]最大数maxnumber
- leetcode- Delete Node in a Linked List&Remove Linked List Elements
- <a href="javascript:void(0)" onclick="ff()" ></a> 用法解析
- 4行代码实现js模板引擎