UVa 10916 - Factstone Benchmark Solution

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector<int> ans(21);
int main(){
    ios::sync_with_stdio(0);
    int n,a=3,j=0;
    double tmp=log(2)+log(3);
    for(int i=4;i<=(4<<20);i<<=1,j++){
        double mx=i*log(2);
        while(tmp<mx){
            ans[j]=a++;
            tmp+=log(a);
        }
    }
    while(cin>>n){
        if(!n)
            return 0;
        cout<<ans[(n-1960)/10]<<endl;
    }
}

Comments