Home > Web Front-end > HTML Tutorial > Codeforces Round #256 (Div. 2) D. Multiplication Table_html/css_WEB-ITnose

Codeforces Round #256 (Div. 2) D. Multiplication Table_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:01:42
Original
1255 people have browsed it

Question link: http://codeforces.com/contest/448/problem/D

Idea: use dichotomy

code:

#include<cstdio>#include<cmath>#include<iostream>using namespace std;__int64 n,m,k;__int64 f(__int64 x){    __int64 res=0;    for(__int64 i=1;i<=n;i++)    {        __int64 minn=min(m,x/i);  //计算第i行有多少个数比x小,并且最多也只要m个数比x小        res+=minn;                //计算出比x小的数的共有多少个    }    return res<k;}int main(){    while(scanf("%I64d%I64d%I64d",&n,&m,&k)==3)    {        __int64 l=1,r=n*m;        while(l<r)        {            __int64 mid=(l+r)/2;            if(f(mid))l=mid+1;            else r=mid;        }        printf("%I64d\n",l);    }    return 0;}
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template