UESTC 65 CD Making 贪心法
来源:互联网 发布:反导技术知乎 编辑:程序博客网 时间:2024/05/22 07:41
CD Making
Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)
Tom has
and he believes the number 13
would bring bad luck, so he will never let a CD contain exactly
possible to record all these songs. Please help him.
Input
There are
record into CDs, and the maximum number of songs a single CD can contain.
Output
For each test case, output the minimum number of CDs required, if the above constraints are satisfied.
Sample input and output
25 213 13
32
Hint
If Tom has
respectively.
In the second case, Tom wants to record
if
he were not so superstitious. However, since he will not record exactly
contains
12
Source
My Solution
#include <iostream>#include <cstdio>using namespace std;int main(){ int T,N,K,ans; scanf("%d",&T); while(T--){ ans=0; scanf("%d%d",&N,&K); if(N<=K) {if(N!=13)printf("1"); else printf("2");} else { if(K==13) {ans=N/12;if(N%12!=0) ans+=1;} else if(K<13||K>14) { ans=N/K; if(N%K!=0) ans+=1; //如果K>14&&N%K==13,只要从另外一个地方补个过来变成14就可以了,不用另外加CD } else { //K==14 ans=N/K; if(N%K!=0){ if(N%K!=13) ans+=1; else ans+=2; } } printf("%d",ans); } if(T) printf("\n"); } return 0;}
- UESTC 65 CD Making 贪心法
- UESTC 1143.CD Making
- uestc水题CD Making
- CD Making
- CD Making
- CD Making
- TOJ 2776 CD Making
- CD Making 逻辑数学题
- UESTC 1255 斓少摘苹果 贪心法
- UESTC 1018 王之新学期 贪心法
- UESToj 64 CD Making ( 水题
- Making a GRUB bootable CD-ROM
- UESTC 1263 The Desire of Asuna 贪心法&&构造法
- UESTC 1013 我的魔法栈 贪心法
- UESTC 1251 谕神的密码 贪心法
- UESTC 1261 被神选中的人 贪心法
- UESTC--1271--Search gold(贪心)
- UESTC 86 Divide (二进制贪心)
- CSS 之float clear
- jquery ajax异步请求json数据
- C语言开发总结(十四)
- Powerdesigner中文和英文自动映射
- Hibernate中映射枚举类型
- UESTC 65 CD Making 贪心法
- bzoj1007 [HNOI2008]水平可见直线
- Spark 提交任务时,报: Invalid signature file digest for Manifest main attributes
- plyr package
- Java算法---马戏团和整理图书编程题
- HTML和CSS学习笔记(一)
- java设计模式----工厂设计模式
- C++拷贝构造函数详解 http://blog.csdn.net/lwbeyond/article/details/6202256
- visio绘制流程图-去掉默认的左侧栏(小例)