HDU 6033(數學)

這題還是有必要記錄一下的
題意:

2m1<=10k

已知m求最小的k
題解:關鍵在於用2m=10a+b 來表示,其中a是2m 的整數部分,b是小數部分
log102m=a+b
mlog102=a+b
a=mlog102
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <sstream>
#define LL long long
#define INF 0x3f3f3f3f
#define mod 1000000007
const int maxn = 300000+5;
using namespace std;
int main(){
    int m, kases = 1;
    while(scanf("%d",&m) == 1){
        double k = m*log(2.0)/log(10.0);
        printf("Case #%d: %d\n",kases++,(int)k);
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章