I do not know whether it is my level of improvement or the problem of CF becomes water ...
A-vanya and Cubes
Water problem. Brute force enumeration can be:
The code is as follows:
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include < stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #include <map> #include < Set> #include <algorithm>using namespace std; #define LL __int64const int inf=0x3f3f3f3f;int s[100], sum[100]; int main () { int n, i; S[1]=1; Sum[i]=1; scanf ("%d", &n); for (i=2;i<=10000;i++) { s[i]=s[i-1]+i; Sum[i]=sum[i-1]+s[i]; if (sum[i]>=n) break; } printf ("%d\n", i-1); return 0;}
B-vanya and Lanterns
Water problem. Violence find the shortest distance between two neighbors/2, and then find the longest distance from the boundary.
The code is as follows:
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include < stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #include <map> #include < Set> #include <algorithm>using namespace std; #define LL __int64const int inf=0x3f3f3f3f;int a[2000];int main () { int N, L, I, J; Double D, Max1=-1; scanf ("%d%d", &n,&l); a[0]=0; a[n+1]=l; for (i=1;i<=n;i++) { scanf ("%d", &a[i]); } Sort (a,a+n+2); for (i=2;i<=n;i++) { Max1=max (max1, (a[i]-a[i-1])/2.0); } Max1=max (max1,a[1]-0.0); Max1=max (Max1,l*1.0-a[n]); printf ("%.10lf\n", max1); return 0;}
C-vanya and Exams
Greedy.
Accumulate from the beginning of the few papers required.
The code is as follows:
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include < stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #include <map> #include < Set> #include <algorithm>using namespace std; #define LL __int64const int inf=0x3f3f3f3f;struct node{LL F, e;} Fei[110000];int CMP (node x, node Y) {return x.e<y.e;} int main () {int i; LL N, R, Ave, S, SUM, SS, Ans=0; scanf ("%i64d%i64d%i64d", &n,&r,&ave); Sum=n*ave; s=0; for (i=0;i<n;i++) {scanf ("%i64d%i64d", &FEI[I].F,&FEI[I].E); S+=FEI[I].F; } ss=sum-s; if (ss<=0) {printf ("0\n"); return 0; } sort (fei,fei+n,cmp); printf ("%d\n", SS); for (i=0;i<n;i++) {if (fei[i].f>=r) continue; if (ss-(R-FEI[I].F) <=0) {ans+=SS*FEI[I].E; Break } else{ss-=r-fei[i].f; ans+=fei[i].e* (R-FEI[I].F); }//printf ("%d\n", SS); } printf ("%i64d\n", ans); return 0;}
D-vanya and Computer Game
The game when the thought of two minutes, find the time how to judge who has never thought out. The second genius suddenly dawned. As long as you can judge whether the division is divisible .... Why did not think of it at that time ... Depressed..
Zoom in on the timeline, 1/x and 1/y seconds to Y and X, and then two minutes to find the time to determine whether the division is divisible.
The code is as follows:
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include < stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #include <map> #include < Set> #include <algorithm>using namespace std; #define LL __int64const int Inf=0x3f3f3f3f;int Main () {ll n, x , y, I, Z, Low, High, mid, ans; scanf ("%i64d%i64d%i64d", &n, &x, &y); while (n--) {scanf ("%i64d", &z); Low=1; High=1e16; while (Low<=high) {mid=low+high>>1; if (mid/x+mid/y>=z) {high=mid-1; Ans=mid; } else low=mid+1; } if (ans%x==0&&ans%y==0) puts ("Both"); else if (ans%x==0) puts ("Vova"); Else puts ("Vanya"); } return 0;}
E-vanya and Field
Feel this e-question good water ... First, because GCD is 1, you can ensure that the N number is accessible and not duplicated. So the default is to let him start at some point from the horizontal axis of 0. Then, when the ordinate is 0 o'clock, you can find a mapping between the x-coordinate and the y-coordinate, and save it. Then each input coordinate, you can use the formula to determine the point from which to start. Then find the most out of that starting point.
The code is as follows:
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include < stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #include <map> #include < Set> #include <algorithm>using namespace std; #define LL __int64const int inf=0x3f3f3f3f;int _hash[1100000], a[ 1100000];int Main () {int n, m, dx, DY, I, J, X, Y, POS, max1; scanf ("%d%d%d%d", &n,&m,&dx,&dy); x=y=0; for (i=0;i<n;i++) {a[x]=y; x= (X+DX)%n; Y= (Y+dy)%n; } memset (_hash,0,sizeof (_hash)); while (m--) {scanf ("%d%d", &x,&y); _hash[(y+n-a[x])%n]++; } max1=-1; for (i=0;i<n;i++) {if (Max1<_hash[i]) {max1=_hash[i]; Pos=i; }} printf ("0%d\n", POS); return 0;}
Codeforces Round #280 (Div. 2) Problem solving report A.B.C.D.E.