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); } } }