Problem A:
错误的代码:
#include #include using namespace std; const int MAXN = 5010; int n, ans = 0, a[MAXN]; int main() { scanf("%d", &n); for(int i = 0; i maxh) { maxh = tmp; s = ts; t = tt; } } } else { if(tmp > maxh) { maxh = tmp; s = ts; t = tt; } tmp = 0; first = 1; } } if(maxv > maxh) { *max_element(a, a + n) = 0; } else { for(int i = s; i
代码:
#include #include using namespace std;const int MAXN = 5010;int n, a[MAXN];int solve(int l, int r){ if(l > r) return 0; int minh = *min_element(a + l, a + r + 1); int ret = r - l + 1, tot = minh; if(ret
Problem D:
D. Multiplication Table
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 ann?×?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 test(s)
input
2 2 2
output
input
2 3 4
output
input
1 10 5
output
传送门: 点击打开链接解题思路:
二分。需要求的是n*m乘法表中第k大的数,我们可以对这个数ans进行二分查找,区间是[1, n * m],对于每一个可能的ans,我们求出比他小的数的个数sum += min((mid - 1) / i, m);(i = 1,2,3,..,n),记录下小于k的最大的mid,即为我们所求的ans。
代码:
#include inline long long min(long long a, int b){ if(a > 1; sum = 0; for(int i = 1; i
查看更多关于CodeforcesRound#256(Div.2)题解_html/css_WEB-ITnose的详细内容...