标签:style blog io color os sp div log bs
1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 int Height,WorkNum; 5 int TotalNum; 6 int AllCatsHeight,mid; 7 int Left = 1,Right=10000; 8 int main() 9 { 10 while(cin>>Height>>WorkNum,Height+WorkNum){ 11 TotalNum = 1; 12 AllCatsHeight = Height; 13 Left = 1,Right=10000000; 14 while(Left){ 15 mid = (Left + Right)/2; 16 if(fabs(log(Height) * log(mid) - log(WorkNum)* log(mid + 1))<=0.00001)break; 17 if(log(Height) * log(mid) - log(WorkNum)* log(mid + 1)>0)Right = mid; 18 else Left = mid; 19 } 20 int Every = 1; 21 while(Height > 1){ 22 Height /= (mid + 1); 23 Every *= mid; 24 AllCatsHeight += (Height * Every); 25 TotalNum += Every; 26 } 27 cout<<TotalNum - WorkNum<<" "<<AllCatsHeight<<endl; 28 } 29 return 0; 30 }
题意就不多说了,就是猫变猫。
做这个题需要的是数学好,,,,思路很简单。
做了好几个小时,老是超时,改动好多次才好,最后也不知道怎么好的,晕。
以后卡壳了还是做点别的换换思路,不能像今天一样熬这么长时间了,有点得不偿失,切记。
标签:style blog io color os sp div log bs
原文地址:http://www.cnblogs.com/ohxiaobai/p/4066334.html