[ACM ] 107

看板C_and_CPP (C/C++)作者 ( )時間16年前 (2009/04/18 19:38), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
在收到多次的tle跟wa終於受不了了 所以來問問各位大大,不知道問題出在哪邊 ================以下是目前的code=================== #include <stdio.h> #include <math.h> int main() { unsigned long h,c; while( scanf("%lu%lu",&h,&c) ) { if((!h) || (!c))break; if(h==1 && c==1) { printf("0 1\n"); continue; } unsigned long N = 1; int k; if(c==1) k=(int)( (float)log(h) / (float)log(2) ); else { while( ++N ) { if(fabs( ((float)log(c)/(float)log(N))- ((float)log(h)/(float)log(N+1)) ) < 0.0001) { k=(int)((float)log(c) / (float)log(N)); break; } } } unsigned long SumOfNothing=0,SumOfHeight=c; int height=h,nothing=1; for(int i=0 ; i<k ; height /= (N+1), nothing *= N, ++i) { SumOfNothing += nothing; SumOfHeight += height*nothing; } printf("%lu %lu\n",SumOfNothing,SumOfHeight); } return 0; } ========================以上code====================== -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.126.232.187 ※ 編輯: frank99977 來自: 59.126.232.187 (04/19 00:25)
文章代碼(AID): #19wRktBa (C_and_CPP)
討論串 (同標題文章)
以下文章回應了本文
1
6
完整討論串 (本文為第 1 之 2 篇):
1
6
16年前, 04/18
文章代碼(AID): #19wRktBa (C_and_CPP)