首页 > 代码库 > CF Codeforces Round #256 (Div. 2) D (448D) Multiplication Table

CF Codeforces Round #256 (Div. 2) D (448D) Multiplication Table




二分!!!


AC代码例如以下:



#include<iostream>
#include<cstring>
#include<cstdio>
#define ll long long
using namespace std;

ll n,m,k;

ll work(ll a)
{
    ll i,j;
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        j=a/i;
        if(j>m)
            j=m;
        ans+=j;
    }
    return ans;
}

int main()
{
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    ll l,r,mid;
    l=1;
    r=n*m+1;
    while(l<r)
    {
        mid=(l+r)/2;
        //cout<<mid<<"!!!!!!!!!!!!!!!!!!!!!!"<<work(mid)<<endl;
        if(work(mid)<k) l=mid+1;
        else r=mid;
    }
    cout<<r<<endl;
    return 0;
}


CF Codeforces Round #256 (Div. 2) D (448D) Multiplication Table