Codeforces Round #257 (Div. 2)_html/css_WEB-ITnose
A. Jzzhu and Children
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.
Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm:
- Give m candies to the first child of the line.
- If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home.
- Repeat the first two steps while the line is not empty.
Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?
Input
The first line contains two integers n,?m (1?≤?n?≤?100; 1?≤?m?≤?100). The second line contains n integers a1,?a2,?...,?an (1?≤?ai?≤?100).
Output
Output a single integer, representing the number of the last child.
Sample test(s)
input
5 21 3 1 4 2
output
input
6 41 1 2 2 3 3
output
Note
Let's consider the first sample.
Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.
Child 4 is the last one who goes home.
这道题也就这样。。。
#include#include #include #include #include #include #define INF 0x3f3f3f3fusing namespace std;int main(){ int n, m; int ans = 0, t = 0, a; cin >> n >> m; for (int i = 0; i > a; if (i == 0 || (a+m-1)/m >= t) { ans = i+1; t = (a+m-1)/m; } } cout
还有用队列写的。。这个很方便。。
#includeusing namespace std;const int maxn = 1000 + 10;int n, m;struct node{ int id, cd;};int main(){ int i, j; scanf("%d%d", &n, &m); queue q; for(i=1; im) { cur.cd -= m; q.push(cur); } } printf("%d\n", cur.id); return 0;}
B. Jzzhu and Sequences
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Jzzhu has invented a kind of sequences, they meet the following property:
You are given x and y, please calculate fn modulo 1000000007 (109?+?7).
Input
The first line contains two integers x and y (|x|,?|y|?≤?109). The second line contains a single integer n (1?≤?n?≤?2·109).
Output
Output a single integer representing fn modulo 1000000007 (109?+?7).
Sample test(s)
input
2 33
output
input
0 -12
output
1000000006
Note
In the first sample, f2?=?f1?+?f3, 3?=?2?+?f3, f3?=?1.
In the second sample, f2?=??-?1; ?-?1 modulo (109?+?7) equals (109?+?6).
B题被人HACK了。。。
原来没考虑好为-1的情况。。淡淡的忧桑。。。。
#include#include #include #include #include #include #define INF 1000000007using namespace std;int main(){ int x, y; cin>>x>>y; int n; cin>>n; n %= 6; //6次一循环 int a[10]; a[1]=(x+INF) % INF; a[2]=(y+INF) % INF; a[3]=(a[2]-a[1]+INF) % INF; a[4]=(-x+INF) % INF; a[5]=(-y+INF) % INF; a[0]=(a[1]-a[2]+INF) % INF; n = n%6; cout
C. Jzzhu and Chocolate
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Jzzhu has a big rectangular chocolate bar that consists of n?×?m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:
each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate square with cut); each cut should go inside the whole chocolate bar, and all cuts must be distinct. The picture below shows a possible way to cut a 5?×?6 chocolate for 5 times.
Imagine Jzzhu have made k cuts and the big chocolate is splitted into several pieces. Consider the smallest (by area) piece of the chocolate, Jzzhu wants this piece to be as large as possible. What is the maximum possible area of smallest piece he can get with exactlyk cuts? The area of a chocolate piece is the number of unit squares in it.
Input
A single line contains three integers n,?m,?k (1?≤?n,?m?≤?109; 1?≤?k?≤?2·109).
Output
Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.
Sample test(s)
input
3 4 1
output
input
6 4 2
output
input
2 3 4
output
-1
Note
In the first sample, Jzzhu can cut the chocolate following the picture below:
In the second sample the optimal division looks like this:
In the third sample, it's impossible to cut a 2?×?3 chocolate 4 times.
#include#include #include #include #include #include #define INF 0x3f3f3f3fusing namespace std;long long int n, m, k;long long int i;int main(){ cin >> n >> m >>k; if( k>n+m-2 ) { cout =b ) b = a; i++; } cout
上一篇: PHP 导出数据到淘宝助手CSV的方法分享_PHP教程
下一篇: 如何禁止打印页面_CSS/HTML
推荐阅读
-
Codeforces Round #595 (Div. 3)D1D2 贪心 STL
-
Codeforces Round #655 (Div. 2) A. Omkar and Completion
-
Codeforces Round #487 (Div. 2)
-
Codeforces Round #649 (Div. 2)-B. Most socially-distanced subsequence(思维)
-
Codeforces Round #649 (Div. 2) C-Ehab and Prefix MEXs
-
Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing
-
Codeforces Round #659 (Div. 2) A. Common Prefixes(字符串,思维)
-
Codeforces Round #610 (Div. 2)
-
Codeforces Round #670 (Div. 2)
-
Codeforces Round #665 (Div. 2)