刚刚天真的跑去打codechef,才发现那是IOI模拟赛qwq。

atc是比赛还剩40min结束的时候才打的,就做了前三个题

T1

zz模拟

AtCoder Beginner Contest 103_题型AtCoder Beginner Contest 103_题型_02
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 1e5 + 10, INF = 1e9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int a[5];
int main() {
    a[1] = read(); a[2] = read(); a[3] = read();
    sort(a + 1, a + 4);
    printf("%d", abs(a[2] - a[1]) + abs(a[3] - a[2]));
    return 0;
}
T1

T2

zz模拟

AtCoder Beginner Contest 103_题型AtCoder Beginner Contest 103_题型_02
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
const int MAXN = 1e5 + 10, INF = 1e9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
string a, b;
int main() {
    cin >> a >> b;
    int N = a.length();
    if(N != b.length()) {puts("No"); return 0;}
    //for(int i = 0; i < N; i++) a[i + N] = a[i];
    a = a + a;
    //cout << a << endl << b;
    if(a.find(b) != string::npos) puts("Yes");
    else puts("No");
    return 0;
}
T2

T3

这个就比较厉害了。

首先我们发现,对于每个$a_i$,我们都可以构造一个数使得$x \pmod {a_i} = a_i - 1$

那么输出$\sum_{i = 1}^n a_i - 1$就行了

AtCoder Beginner Contest 103_题型AtCoder Beginner Contest 103_题型_02
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
//#define int long long 
using namespace std;
const int MAXN = 1e5 + 10, INF = 1e9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N;
int a[MAXN], sum = 0;
int check(int val) {
    int ret = 0;
    for(int i = 1; i <= N; i++)
        ret += val % a[i];
    return ret;
}
main() {
    N = read();
    for(int i = 1; i <= N; i++) 
        a[i] = read(), sum += a[i] - 1;
    printf("%d", sum); 
    return 0;
}
T3

T4

首先按照套路按照右端点排序

然后按照从左到右的顺序依次在右端点切就行了

AtCoder Beginner Contest 103_题型AtCoder Beginner Contest 103_题型_02
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#define MP(x, y) make_pair(x, y)
#define Pair pair<int, int> 
//#define int long long 
using namespace std;
const int MAXN = 1e6 + 10, INF = 1e9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, M;
Pair P[MAXN];
main() {
    N = read(); M = read();
    for(int i = 1; i <= M; i++) {
        int x = read(), y = read();
        P[i] = MP(y, x);
    }
    int ans = 0, last = -1;
    sort(P + 1, P + M + 1);
    for(int i = 1; i <= M;) {
        int j = i + 1;
        while(j <= M && P[i].first == P[j].first) j++;
        if(P[j - 1].second >= last) 
            ans++,          = P[j - 1].first;
        i = j;
    }
    printf("%d\n", ans);
    return 0;
}
T4