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 ...
随机推荐
- Windows执行打开文件命令
ShellExecute(NULL, "open", localFile.c_str(), NULL, NULL, SW_SHOW); 会调用该文件类型关联的 ...
- C++11中的右值引用
原文出处:http://kuring.me/post/cpp11_right_reference May 18, 2015 移动构造函数 C++98中的左值和右值 C++11右值引用和移动语义 强制移 ...
- The Stereo Action Dimension
Network MIDI on iOS - Part 1 This is an app I wrote to try out some ideas for networked MIDI on iP ...
- 一排下去再上来的div
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- 移动端rem布局
手机页面——分辨率特别乱: 1.定宽320px——优点:简单,缺点:不能适应 2.百分比——优点:能适应各种分辨率,缺点:太麻烦 3.rem——优点:方便.适应各种分辨率(首先定义一个“根大小”htm ...
- C# Keynote
[C# Keynote] 1. Main 方法必须包含在一个类内,参数类型.返回值类型可以有多种变化. // Hello1.cs public class Hello1 { public static ...
- Working with Other Node Types II
[Working with Other Node Types II] An SKCropNode object does not directly render content, like a spr ...
- Database事件研究
1.Database.ObjectAppended.ObjectModified.ObjectErased事件 此事件如果不是Transaction提交而触发的,那么可以在事件内部使用Transact ...
- unigui 导入导出数据
导入:首先要用TUniFileUpload将文件从客户端上传至服务端,然后完成导入. TUniFileUpload上传文件的演示代码: UniFileUpload1.Execute; UniFileU ...
- Python基础 初识Python
机器码 机器码(machine code),学名机器语言指令,有时也被称为原生码(Native Code),是电脑的CPU可直接解读的数据. 通常意义上来理解的话,机器码就是计算机可以直接执行,并且执 ...