[Team Competition 3]-e Binary Search cf448d

Source: Internet
Author: User
Multiplication table
Time Limit: 1000 ms memory limit: 262144kb 64bit Io format: % i64d & % i64u
Submit

Status

Practice

Codeforces 448d
Description
Bizon the champion isn't just charming, he also is very smart.

While some of us were learning the multiplication table, Bizon the champion had fun in his own manner. Bizon the champion painted an n? ×? M multiplication table, where the element on the intersection of the I-th row and J-th Column equals I · J (the rows and columns of the table are numbered starting from 1 ). then he was asked: what number in the table is the k-th largest number? Bizon the champion always answered correctly and immediately. Can you repeat his success?

Consider the given multiplication table. if you write out all N · m numbers from the table in the non-decreasing order, then the k-th number you write out is called the k-th largest number.

Input
The single line contains integers n, m and K (1? ≤? N ,? M? ≤? 5 · 105; 1? ≤? K? ≤? N · m ).

Output
Print the k-th largest number in a n? ×? M multiplication table.

Sample Input
Input
2 2 2
Output
2
Input
2 3 4
Output
3
Input
1 10 5
Output
5
Hint
A 2? ×? 3 multiplication table looks like this:


1 2 3
2 4 6
<Span style = "color: # 3333ff; Background-color: RGB (255,255,255);">/* revoke Author: grant yuan time: 2014.7.21 algorithm: Binary Search explain: if I * m <= AA, the M number will satisfy the result, otherwise, the number of AA/I will meet the requirements. */# include <iostream> # include <cstdio> # include <cstring> # include <cstdlib> # include <algorithm> # include <queue> # include <functional> # define INF 999999999 using namespace STD; // long a [100003] [100003]; long K; long l, R, mid; long n, m; long m; inline bool can (long aa) {long sum = 0; For (INT I = 1; I <= N; I ++) {if (I * m <= aa) sum + = m; else sum + = AA/I;} If (sum> = k) return true; return false ;} int main () {m = 0; CIN> N> m> K; long ans = 1; L = 1; r = N * m; while (L <= r) {mid = (long) (L + r) * 0.5); If (CAN (MID) {ans = mid; R = mid-1;} else l = Mid + 1;} cout <ans <Endl ;}</span>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.