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[20];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
    while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
    return x*f;
}
inline void P(int x)
{
    Num=0;if(!x){putchar(‘0‘);puts("");return;}
    while(x>0)CH[++Num]=x%10,x/=10;
    while(Num)putchar(CH[Num--]+48);
    puts("");
}
//**************************************************************************************

int main()
{
    //test;
    int T; cin >> T;
    while (T--) {
        int N, K; scanf("%d%d",&N,&K);
        if (K == 13) K = 12;
        if (K < 13) printf("%d\n",N/K + (N % K ? 1 : 0));
        else if (N == 13) printf("2\n");
        else if (K >= 15) printf("%d\n",N/K + (N % K ? 1 : 0));
        else if (K == 14) {
            int r = N % K;
            if (r != 13) printf("%d\n",N / K + (r == 0 ? 0 : 1));
            else printf("%d\n",N / K + 2);
        }
    }
}
时间: 2024-10-10 02:45:21

cdoj 65 CD Making 水题的相关文章

cdoj 26 遮挡判断(shadow) 水题

遮挡判断(shadow) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 Description 在一个广场上有一排沿着东西方向排列的石柱子,阳光从东边以一定的倾角射来(平行光).有的柱子可能被在他东边的高大的柱子的影子给完全遮挡住了.现在你要解决的问题是求出有多少柱子是没有被完全遮挡住的. 假设每个石柱子是一根细棒,而且都垂直于地面摆放. Input 输入包含多组数据

cdoj 24 8球胜负(eight) 水题

8球胜负(eight) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 Description 8球是一种台球竞赛的规则.台面上有7个红球.7个黄球以及一个黑球,当然还有一个白球.对于本题,我们使用如下的简化规则:红.黄两名选手轮流用白球击打各自颜色的球,如果将该颜色的7个球全部打进,则这名选手可以打黑球,如果打进则算他胜.如果在打进自己颜色的所有球之前就把黑球打进,则

hdu5360 Hiking(水题)

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Hiking Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 724    Accepted Submission(s): 384Special Judge Problem Description There are 

hdu 2710 水题

题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简化的部分也不太多 1 #include<iostream> 2 #include<cstring> 3 #include<cmath> 4 #include<cstdio> 5 using namespace std; 6 #define for0n for(i

poj 3264 RMQ 水题

题意:找到一段数字里最大值和最小值的差 水题 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 using namespace std; 8 const int maxn=550; 9 const int INF=0x3f3f3f3f; 10 in

【Floyd(并非水题orz)】BZOJ4093-[Usaco2013 Dec]Vacation Planning

最近刷水太多标注一下防止它淹没在silver的水题中--我成为了本题,第一个T掉的人QAQ [题目大意] Bovinia设计了连接N (1 < = N < = 20,000)个农场的航班.对于任何航班,指定了其中的k个农场作为枢纽. (1 < = K <= 200 , K < = N). 目前,共有M种单向航班( 1 < = M < = 20,000 ),第i个航班从农场u_i至农场v_i花费d_i ( 1 < = d_i < =10,000 )美元.

BestCoder Round #36 (hdu5199)Gunner(水题)

转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Gunner Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Long long ago, there is a gunner whose name is Jack. He likes to go hunting very

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,萌萌的师弟师妹们们经常会让pigofzhou帮他们Debug,因为师弟师妹们打代码使用编程语言的种类千奇百怪,pigofzhou为此很头疼.现在假设师弟师妹们只喜欢Java或者C++或者C,因为他希望所有人都学相同的编程语言,只有这样pigofzhou教