Posted on 2009-06-04 10:58
Hero 阅读(111)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1219 Accepted 0 136 627 C++
2 /*
3 when inm< 13, push as many as posible songs to each CD
4 when inm==13, we can change inm to 12
5 when inm==14, if inn%inm==13, divide 13 to 2 parts
6 when inm> 14, if inn%inm==13, divide the songs of last 2 CDs to 2 parts
7 */
8 #include <iostream>
9 #include <string>
10 #include <algorithm>
11 using namespace std ;
12
13 const int size = 2000 ;
14
15 int tnum ;
16 int inn, inm ;
17
18 int main()
19 {
20 while( cin >> tnum )
21 {
22 while( tnum -- )
23 {
24 scanf( "%d %d", &inn, &inm ) ;
25 if( inm == 13 ) inm = 12 ;
26
27 int out = 0 ;
28 if( inm < 13 )
29 {
30 out = (inn+inm-1) / inm ;
31 }
32 else if( inm == 14 )
33 {
34 int inx = inn % inm ;
35 out = (inn+inm-1) / inm ;
36 if( inx == 13 ) out += 1 ;
37 }
38 else
39 {
40 int inx = inn % inm ;
41 out = (inn+inm-1) / inm ;
42 }
43
44 printf( "%d\n", out ) ;
45 }
46 }
47
48 return 0 ;
49 }