算法实践1.1 intel fastpone

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int qmi(int a, int k)  // 求a^k mod p
{
    
    
    int res = 1 ;
    while (k)
    {
    
    
        if (k & 1) res = (long long)res * a ;
        a = (long long)a * a ;
        k >>= 1;
    }
    return res;
}

int main()
{
    
    
    int n;
    while(cin>>n,n){
    
    
        int t=n-1940;
        t/=10;
        double tt=qmi(2,t);
        double ans=0;

        for(int i=2;;i++){
    
    
            ans+=log2(i);

            if(ans>tt){
    
    
                cout<<i-1<<endl;
                break;
            }
        }

    }
}

猜你喜欢

转载自blog.csdn.net/weixin_39057744/article/details/121106851