cdoj 65 CD Making 水题
CD Making
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://acm.uestc.edu.cn/#/problem/show/65
Description
Tom has N songs and he would like to record them into CDs. A single CD can contain at most K songs. In addition, Tom is very superstitious and he believes the number 13 would bring bad luck, so he will never let a CD contain exactly 13 songs. Tom wants to use as few CDs as possible to record all these songs. Please help him.
Input
There are T test cases. The first line gives T, number of test cases. T lines follow, each contains N and K, number of songs Tom wants to record into CDs, and the maximum number of songs a single CD can contain.
1≤N≤1000,1≤K≤1000
Output
For each test case, output the minimum number of CDs required, if the above constraints are satisfied.
Sample Input
2
5 2
13 13
Sample Output
3
2
HINT
题意
题解:
讨论讨论,麻烦……
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 200000
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** int main()
{
//test;
int T; cin >> T;
while (T--) {
int N, K; scanf("%d%d",&N,&K);
if (K == ) K = ;
if (K < ) printf("%d\n",N/K + (N % K ? : ));
else if (N == ) printf("2\n");
else if (K >= ) printf("%d\n",N/K + (N % K ? : ));
else if (K == ) {
int r = N % K;
if (r != ) printf("%d\n",N / K + (r == ? : ));
else printf("%d\n",N / K + );
}
}
}
cdoj 65 CD Making 水题的更多相关文章
- CDOJ 481 Apparent Magnitude 水题
Apparent Magnitude Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/sh ...
- cdoj 26 遮挡判断(shadow) 水题
遮挡判断(shadow) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...
- cdoj 24 8球胜负(eight) 水题
8球胜负(eight) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 ...
- CF 628B New Skateboard --- 水题
CD 628B 题目大意:给定一个数字(<=3*10^5),判断其能被4整除的连续子串有多少个 解题思路:注意一个整除4的性质: 若bc能被4整除,则a1a2a3a4...anbc也一定能被4整 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- hdu 3835:R(N)(水题,数学题)
R(N) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- Poj1298_The Hardest Problem Ever(水题)
一.Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar eve ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
随机推荐
- eclipse 在Navigator视图中查看资源
随着不断使用Eclipse,Navigator视图中的实体数目会增加.通过在某一项目或文件夹上右击,并在所出现的快捷菜单中选择Go Into命令,你就可以查看该项目或文件夹中的资源了.此时Naviga ...
- 说说Python 中的文件操作 和 目录操作
我们知道,文件名.目录名和链接名都是用一个字符串作为其标识符的,但是给我们一个标识符,我们该如何确定它所指的到底是常规文件文件名.目录名还是链接名呢?这时,我们可以使用os.path模块提供的isfi ...
- 两个队列+k叉哈夫曼树 HDU 5884
// 两个队列+k叉哈夫曼树 HDU 5884 // camp题解: // 题意:nn个有序序列的归并排序.每次可以选择不超过kk个序列进行合并,合并代价为这些序列的长度和.总的合并代价不能超过TT, ...
- jq 选项卡
<!doctype html> <html> <head> <meta charset="utf-8"> <style> ...
- Hadoop MapReduce概念学习系列之shuffle大揭秘(十九)
shuffle是非常重要!一定要深入理解和多实践. 缓存,分组,排序,转发,这些都是mr的shuffle. Soga 我想得到按流量来排序,而且还是倒序,怎么达到实现呢?这就牵扯到排序的的问题 默认是 ...
- MYSQL数据库性能调优之六:备份
增量备份
- C++11类型推导
[C++11类型推导] auto 关键字.这会依据该初始化子(initializer)的具体类型产生参数: 除此之外,decltype 能够被用来在编译期决定一个表示式的类型. 参考:http://z ...
- oracle不用tsname文件的时候着怎么办
oracle\product\10.2.0\client_2\odp.net\PublisherPolicy\Policy.9.2.Oracle.DataAccess.config 找到newVers ...
- URAL 2067 Friends and Berries (推理,数学)
题意:给定 n 个人,每个人两个值s, r,要满足,p(v, u) = sqrt((sv − su)^2 + (rv − ru)^2), p(v,u,w) = (p(v,u) + p(v,w) + p ...
- Linux下如何用vi编辑和保存文件
vi是Linux终端下或控制台下常用的编辑器,基本的操作方式为:vi /路径/文件名 例如,vi /etc/fstab表示显示/etc/fstab文件的内容.使用键盘上的Page Up和Page Do ...