Comet OJ - Contest #4

A problem commotion season of girls

Water problem

AC Code:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 typedef unsigned long long ull;
 5 
 6 namespace io {
 7     const int SIZE = 1e7 + 10;
 8     char inbuff[SIZE];
 9     char *l, *r;
10     inline void init() {
11         l = inbuff;
12         r = inbuff + fread(inbuff, 1, SIZE, stdin);
13     }
14     inline char gc() {
15         if (l == r) init();
16         return (l != r) ? *(l++) : EOF;
17     }
18     void read(int &x) {
19         x = 0; char ch = gc();
20         while(!isdigit(ch)) ch = gc();
21         while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
22     }
23 } using io::read;
24 
25 int main(){
26     int t;
27     cin>>t;
28     int a[6];
29     int tmp;
30     while (t--){
31         memset(a, 0, sizeof(a));
32         for (int i = 0; i < 5; i++){
33             cin>>tmp;
34             a[tmp]++;
35         }
36         int max_a = a[1], flag = 1;
37         for (int i = 2; i <= 5; i++){
38             if (a[i] > max_a){
39                 max_a = a[i];
40                 flag = i;
41             }
42         }
43         cout<<flag<<endl;
44     }
45     return 0;
46 }

 

B题 奇偶性

 

 

规律题(但我那天晚上把l写成了1改了一晚上都没改出来导致没有ac掉(太过于愚蠢了

AC代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

namespace io {
    const int SIZE = 1e7 + 10;
    char inbuff[SIZE];
    char *l, *r;
    inline void init() {
        l = inbuff;
        r = inbuff + fread(inbuff, 1, SIZE, stdin);
    }
    inline char gc() {
        if (l == r) init();
        return (l != r) ? *(l++) : EOF;
    }
    void read(int &x) {
        x = 0; char ch = gc();
        while(!isdigit(ch)) ch = gc();
        while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
    }
} using io::read;

int main(){
    int t;
    cin>>t;
    ll l, r, k;
    while (t--){
        cin>>l>>r>>k;
        if (k & 1) cout<<r - l + 1<<endl;
        else cout<<r - l + 1 - (r + 1) / (k + 1) + (l + 1) / (k + 1)<<endl;
    }
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/Misuchii/p/10969391.html