A. Cashier
Test instructions: Give n time period (no cross), in total time L, how many a time period can smoke.
#include <bits/stdc++.h>using namespacestd;structLine {intL,r; BOOL operator< (ConstLine & RHS)Const { returnR <RHS.R; }};intMain () {intN,l,a; Vector<Line>v; //freopen ("In.txt", "R", stdin);scanf"%d%d%d",&n,&l,&a); for(inti =0; I < n; i++) { intl,t; scanf ("%d%d",&l,&t); V.push_back (line{l,l+T}); } sort (V.begin (), V.end ()); intAns =0; for(inti =0; I < (int) V.size ()-1; i++) {ans+ = (v[i+1].L-V[I].R)/A; } if(n>0) { if(l>v[n-1].r) {ans+ = (l-v[n-1].R)/A; } if(v[0].l>0) ans+=v[0].l/A; } Else{ans+ = l/A; } cout<<ans<<Endl; return 0;}
View Code
B. ForgeryTest instructions: To a map, you can draw a 3*3 to the center of the map (this diagram needs to be completely in the picture), asked whether the picture could be completed.
#include <bits/stdc++.h>using namespacestd;Const intMAXN = ++5;CharMAPS[MAXN][MAXN];intn,m;intdx[8] = {-1,-1,-1,0,0,1,1,1};intdy[8] = {-1,0,1,-1,1,-1,0,1};BOOLInsideintXinty) {BOOLFlag =true; if(x>=1&&x< (n1) &&y>=1&&y< (M-1)) { for(inti =0; I <8; i++) { intDr = x +Dx[i]; intDC = y +Dy[i]; if(maps[dr][dc]=='.') Flag=false; } } ElseFlag =false; returnFlag;}BOOLCalcintIintj) {if(Inside (i1, J-1))return true; if(Inside (i1, j))return true; if(Inside (i1, j+1))return true; if(Inside (i,j-1))return true; if(Inside (i,j+1))return true; if(Inside (i+1, J-1))return true; if(Inside (i+1, j))return true; if(Inside (i+1, j+1))return true; return false;}intMain () {//freopen ("In.txt", "R", stdin);scanf"%d%d",&n,&m); for(inti =0; I < n; i++) scanf ("%s", Maps[i]); BOOLFlag =true; for(inti =0; I < n; i++) { for(intj =0; J < M; J + +) { if(maps[i][j]=='#') { if(!Calc (i,j)) {Flag=false; Break; } } } if(!flag) Break; } printf ("%s\n", Flag?"YES":"NO"); return 0;}
View Code
C. Sequence TransformationTest instructions: Given the number of 1~n, each time to seek gcd, arbitrarily delete one of the number, the resulting GCD sequence of the largest dictionary order. Analysis: The dictionary order is the largest, first delete all odd, then 2, and so on, should pay attention to when the number of <=3, the need for a special sentence, equal to 3 o'clock, in accordance with the order.
#include <bits/stdc++.h>using namespacestd;intMain () {intN; scanf ("%d",&N); intres =1; while(n>3) { for(inti =1; I <= (n+1)/2; i++) printf ("%d", RES); Res*=2; N/=2; } if(n==1) printf ("%d\n", RES); Else if(n==2) printf ("%d%d\n", res,res*2); Else if(n==3) printf ("%d%d%d\n", res,res,res*3); return 0;}
View Code
Codeforces Round #514 (Div. 2)