銆愯吘璁?┈鎷夋澗3鏈?3鏃ャ?HDU 4525_濞佸▉鐚?郴鍒楁晠浜嬧?鈥斿悆楦¤吙鏉ユ簮錛?a hrefhttp://acm.hdu.ed
銆愯吘璁?┈鎷夋澗3鏈?3鏃ャ?HDU 4525_濞佸▉鐚?郴鍒楁晠浜嬧?鈥斿悆楦¤吙
鏉ユ簮錛?a href="http://acm.hdu.edu.cn/showproblem.php?pid=4525">鐐瑰嚮鎵撳紑閾炬帴
澶ф按棰橈紝浣嗘槸褰撴椂鎬庝箞涔熸兂涓嶈搗鏉ュ仛鐨勬柟娉曚簡銆傘?鎴栬?璇撮敊鍦ㄥ摢浜嗐?
鍏?紡鍙?互閫氳繃浠庝笂寰?笅鍔犺搗鏉ュ緱鍒幫細a(n+1)=(k1+k2)*an錛屼絾鏄?敤__int64鐨勮瘽涔熸槸涓嶈?鐨勶紝鍥犱負寰?幆璋冪敤鐨勬椂鍊欎細鏈変腑闂存暟鎹?秴杩嘷_int64鐨勮寖鍥淬?姝hВ鏄?敤double,鍙﹀?鏈変竴涓?殣鍚?潯浠舵槸k1,k2閮芥槸鏁存暟(鎻忚堪涓??浜嗗悧 似涔庢病鏈? =)銆傘?杩欐牱灝卞緢瀹規槗鍒ゆ柇inf浜嗐?銆?/p>
#include <iostream>#include <cstring>using namespace std;int main(){double res,k1,k2,notbig;int testcase;cin>>testcase;for(int a=1;a<=testcase;a++){res=0;int orgn;double temp;int count=0;cin>>orgn>>k1>>k2>>notbig;for(int i=0;i<orgn;i++){cin>>temp;res+=temp;}if(res>notbig){cout<<"Case #"<<a<<": "<<0<<endl;}else if(k1+k2>=-1 && k1+k2<=1){cout<<"Case #"<<a<<": "<<"inf"<<endl;}else{while(res<=notbig){res*=(k1+k2);count++;}cout<<"Case #"<<a<<": "<<count<<endl;}}return 0;}