BZOJ2048: [2009国家集训队]书堆

Time Limit: 10 Sec  Memory Limit: 259 MB
Submit: 1649  Solved: 724
Description

Input

第一行正整数 N M

Output

一行(有换行符),L,表示水平延伸最远的整数距离 (不大于答案的最大整数)

Sample Input

样例
#1
Input:1 100
Output:49

#2
Input:2 100
Output:74

Sample Output

N <= 10^18
数据保证答案 < 10^6

/**************************************************************

    Problem: 2048

    User: ictsing

    Language: C++

    Result: Accepted

    Time:0 ms

    Memory:1300 kb

****************************************************************/

 

#include<iostream>

#include<cstdio>

#include<cmath>

#define eps 1e-10

#define r 0.5772156649

using namespace std;

typedef long long ll;

int main()

{

    ll n,m;double ans=0;

    scanf("%lld%lld",&n,&m);

    if(n<=10000)

        for(ll i=1;i<=n;i++) ans=ans+(double)0.5/i;

    else ans=log(n+1.0)+r,ans/=2.0;

    ans*=m;

    printf("%d\n",(int)(ans-eps));

    return 0;

}

 


评论

热度(6)