Codeforces Round #564 (Div. 2)

Portal

 

A. Nauuo and Votes

B. Nauuo and Chess

 

 

References:

  [1]: the Chinese Editoria

 

A. Nauuo and Votes

Meaning of the questions:

  Personal voted yes x, y people voted, z people uncertain;

  This z is personal to you to decide the votes cast for or against;

  Determine whether the x and y determine the relative size?

answer:

  If x == y && z == 0, outputs '0';

  If xy> z, the output of '+';

  If yx> z, output '-';

  On the other hand, the output of '?';

AC Code:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define INF 0x3f3f3f3f
 4 #define ll long long
 5 #define mem(a,b) memset(a,b,sizeof(a))
 6 #define memF(a,b,n) for(int i=0;i <= n;a[i++]=b);
 7 const int maxn=1e3+50;
 8 
 9 int x,y,z;
10 
11 char *Solve()
12 {
13     if(x == y && z == 0)
14         return "0";
15     if(x-y > z)
16         return "+";
17     if(y-x > z)
18         return "-";
19     return "?";
20 }
21 int main()
22 {
23 //    freopen("C:\\Users\\hyacinthLJP\\Desktop\\in&&out\\contest","r",stdin);
24     scanf("%d%d%d",&x,&y,&z);
25     puts(Solve());
26 
27      return  0 ;
28 }
View Code

 


B. Nauuo and Chess

Meaning of the questions:

  N give you a pawn, to meet the demand "for all pairs of pieces i and J,  | R & lt I - R & lt J | + | C I - C J ≥  . | I-J | "checkerboard minimum square column;

answer:

  From the lower right corner of the square of the board (m, m) of the upper left corner (1,1) is 2 × (m-1);

  ① Found 2 × (m-1) ≥ n-1 m of the minimum;

  ② The 1 ~ n-1 pawn from the first row begins to fill, completely fill the first row, the last one is filled;

AC Code:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define memF(a,b,n) for(int i=0;i <= n;a[i++]=b);
 4 #define INF 0x3f3f3f3f
 5 const int maxn=2e5+50;
 6 
 7 int n;
 8 
 9 void Solve()
10 {
11     int m=(n+2)/2;
12     printf("%d\n",m);
13     int x=1,y=1;
 14      for ( int I = . 1 ; I <n-; ++ I)
 15      {
 16          the printf ( " % D% D \ n- " , X, Y);
 . 17          IF (Y <m) /// to fill the first line 
18 is              Y ++ ;
 . 19          the else 
20 is              X ++ ;
 21 is      }
 22 is      the printf ( " % D% D \ n- " , m, m);
 23 is  }
 24  int main ()
 25  {
 26 is      Scanf ( " % D",&n);
27     Solve();
28 
29     return 0;
30 }
View Code

 

Guess you like

Origin www.cnblogs.com/violet-acmer/p/10989957.html