zoukankan      html  css  js  c++  java
  • 取log比较大小

    http://poj.org/problem?id=2661

    题意:给定n, 2n > k! . 求最大的k

    解法:两边取log比较。

    //#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <iostream>
    #include <string>
    #include <stdio.h>
    #include <queue>
    #include <stack>
    #include <map>
    #include <set>
    #include <string.h>
    #include <vector>
    #define ME(x , y) memset(x , y , sizeof(x))
    #define SF(n) scanf("%d" , &n)
    #define rep(i , n) for(int i = 0 ; i < n ; i ++)
    #define INF  0x3f3f3f3f
    #define mod 20191117
    #define PI acos(-1)
    using namespace std;
    typedef long long ll ;
    
    int main()
    {
        int n ;
        while(~scanf("%d" , &n) && n)
        {
            double w = 2 ;
            for(int i = 1960 ; i <= n ; i+=10)
            {
                w *= 2 ;
            }
            w *= log(2);
            int ans = 1 ;
            double f=0 ;
            while(w >= f)
            {
                f += log((double)++ans);
            }
            cout << ans - 1 << endl ;
        }
        return 0;
    }
    
  • 相关阅读:
    AOV网和AOE网对比
    AOV网和AOE网对比
    Python类型总结
    Python数据结构
    Django之认证系统
    day22笔记
    数据库概念知识
    pymsql模块使用
    多表查询(子查询)
    多表查询(链接查询)
  • 原文地址:https://www.cnblogs.com/nonames/p/12219115.html
Copyright © 2011-2022 走看看