CodeForces, codeforce

Source: Internet
Author: User

CodeForces, codeforce

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 paintedNLimit × limitMMultiplication table, where the element on the intersection ofI-Th row andJ-Th column equalsI·J(The rows and columns of the table are numbered starting from 1). Then he was asked: what number in the table isK-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 allN·MNumbers from the table in the non-decreasing order, thenK-Th number you write out is calledK-Th largest number.

Input

The single line contains integersN,MAndK(1 digit ≤ DigitN, Bytes,MLimit ≤ limit 5 · 105; 1 digit ≤ DigitKLimit ≤ limitN·M).

Output

PrintK-Th largest number inNLimit × limitMMultiplication table.

Sample Input

Input
2 2 2
Output
2
Input
2 3 4
Output
3
Input
1 10 5
Output
5

Hint

A 2 rows x rows 3 multiplication table looks like this:

1 2 32 4 6

Question: The Matrix of n rows and m columns. The value of column j in row I is I * j. The n * m numbers are arranged in a non-descending sequence, ask what the number of k is.

Idea: If sort is used, it must time out. However, we found that each row of the matrix is arranged in a non-descending sequence, which is in line with the property of the binary method. Let's assume that mid is the k Number. We can calculate the number of mid in each row and compare them with k. If the number is greater than k, we need to reduce the number of mid. Otherwise, we will increase the number of mid.

Code ::

# Include <iostream> # include <sstream> # include <ios> # include <iomanip> # include <functional> # include <algorithm> # include <vector> # include <string> # include <list> # include <queue> # include <deque> # include <stack> # include <set> # include <map> # include <cstdio> # include <cstdlib> # include <cmath> # include <cstring> # include <climits> # include <cctype> using namespace std; # define XINF INT_MAX # define INF 0x3FFFFFFF # Define MP (X, Y) make_pair (X, Y) # define PB (X) push_back (X) # define REP (X, N) for (int X = 0; X <N; X ++) # define REP2 (X, L, R) for (int X = L; X <= R; X ++) # define DEP (X, r, L) for (int X = R; X> = L; X --) # define CLR (A, X) memset (A, X, sizeof ()) # define IT iteratortypedef long ll; typedef pair <int, int> PII; typedef vector <PII> VII; typedef vector <int> VI; // const int MAXN = 10010; // # define INF 0x3FFFFFFF /************************* * ************************* Header file ************* **************************************** **/ll n, m, k; int main () {while (cin> n> m> k) {ll l = 1, r = m * n, mid; // while (l! = R) {mid = (l + r)/2; ll tot = 0; // record the mid position REP2 (I, 1, n) {ll x = mid/I; tot + = (x <= m )? (X): m; // The Position of the mid in each row is not greater than the maximum number of columns} if (tot <k) l = mid + 1; else r = mid ;} cout <l <endl;} return 0 ;}











Copyright statement: You can browse it at will.

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.