Open a new account and press codeforces (the old one was used up). The result was so difficult. The touristd question is stuck (in fact, it is too confident in the CF evaluation machine), g question is not passed, more than 700 lines of code, the code force is amazing.
I did four things and thought about the blue name. Then I got down to the second question and found that the circular section was wrong. Despair ~~~~
Game Portal: http://codeforces.com/contest/1043
A. Elections
This question is very simple, that is, there are n people, each of whom cast K tickets for you or your opponent. I will vote for your opponent in AI, so that you can seek the minimum K. This gives you more votes than your opponent. Just simulate it. However, I was so stupid that I forgot K> = max {ai} and Wa once.
Put my code weak
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#define rep(x, l, r) for(int x = l; x <= r; x++)#define repd(x, r, l) for(int x = r; x >= l; x--)#define clr(x,y) memset(x, y, sizeof(x))#define mp(x, y) make_pair(x, y)#define INF 1 << 30#define MAXN using namespace std;typedef long long LL;typedef pair<int,int> par;int main(){ int n; scanf("%d", &n); int sum = 0, maxx = 0; rep(i, 1, n){ int x; scanf("%d", &x); sum += x; maxx = max(maxx, x); } int ans = 2 * sum / n + 1; if(ans < maxx) ans = maxx; printf("%d\n", ans); return 0;}
B. Lost Array
This question is to give you an array a with a length of N, satisfying (k is the length of X ). If K = 3, x = {1, 2, 3}, n = 5, A is like.
Let you calculate the number sum of all x arrays, and the length of each scheme K (from large to small ).
This question seems very troublesome, but it is actually very simple. As long as the adjacent variance is obtained, it is an X solution. The other solutions are composed of the difference loop section (why? Try it on your own ).
However, I am looking for a loop, and I don't know why. The main reason is that the Code is too ugly. Later, I listened to the advice from the boss and improved a little.
Code after modification
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#define rep(x, l, r) for(int x = (int)l; x <= (int)r; x++)#define repd(x, r, l) for(int x = (int)r; x >= (int)l; x--)#define clr(x,y) memset(x, y, sizeof(x))#define mp(x, y) make_pair(x, y)#define INF 1 << 30#define MAXN 1005using namespace std;typedef long long LL;typedef pair<int,int> par;int n;int a[MAXN], b[MAXN], ansk[MAXN];bool judge(int len){ rep(i, len, n - 1) if(a[i] != a[i % len]) return 0; return 1;}int main(){ scanf("%d", &n); rep(i, 1, n){ scanf("%d", &b[i]); a[i - 1] = b[i] - b[i - 1]; } int ans = 0; rep(i, 1, n) if(judge(i)) ansk[++ans] = i; printf("%d\n", ans); rep(i, 1, ans) printf("%d ", ansk[i]); puts(""); return 0;}
C. Smallest word
This question ...... CF's rating remains unchanged. Go to bed and try again tomorrow night.
Codeforces round #519 by Botan investments