Posted on 2006-04-04 21:41
BinGo and WhitNey's 阅读(122)
评论(0) 编辑 收藏 引用
1 class NewAlbum
2 {
3 public:
4 int leastAmountOfCDs(int nSongs, int length, int cdCapacity)
5 {
6 int m = (cdCapacity+1)/(1+length);
7 if (m%13 ==0 ) m--;
8 int result = nSongs/m + (nSongs%m? 1:0);
9 if ((nSongs/m ==0 || nSongs%m+1==m ) && nSongs%m%13==0 && nSongs%m )
10 result++;
11 return result;
12 }
13 };