• Educational Codeforces Round 79做题记录


    Educational Codeforces Round 79做题记录

    这套题感觉出的不咋滴,第四题和第五题难度差了1000分!!!

    前四题都还简单,第五题就31人做出……我算了……

    懒得写题解了,做个记录吧(这就是偷懒的理由???)

    比赛传送门

    A.New Year Garland

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 #include <cstring>
     5 #include <vector>
     6 #define rep(x, l, r) for(int x = l; x <= r; x++)
     7 #define repd(x, r, l) for(int x = r; x >= l; x--)
     8 #define clr(x, y) memset(x, y, sizeof(x))
     9 #define all(x) x.begin(), x.end()
    10 #define pb push_back
    11 #define mp make_pair
    12 #define MAXN
    13 #define fi first
    14 #define se second
    15 #define SZ(x) ((int)x.size())
    16 using namespace std;
    17 typedef long long ll;
    18 typedef vector<int> vi;
    19 typedef pair<int, int> pii;
    20 const int INF = 1 << 30;
    21 const int p = 1000000009;
    22 int lowbit(int x){ return x & (-x);}
    23 int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}
    24 
    25 int main(){
    26     int t;
    27     scanf("%d", &t);
    28     while(t--){
    29         int a, b, c;
    30         scanf("%d%d%d", &a, &b, &c);
    31         if(a < b) swap(a, b);
    32         if(a < c) swap(a, c);
    33         if(a - 1 > b + c) puts("No");
    34         else puts("Yes");
    35     }
    36     return 0;
    37 }
    View Code-A

    B.Verse For Santa

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 #include <cstring>
     5 #include <vector>
     6 #define rep(x, l, r) for(int x = l; x <= r; x++)
     7 #define repd(x, r, l) for(int x = r; x >= l; x--)
     8 #define clr(x, y) memset(x, y, sizeof(x))
     9 #define all(x) x.begin(), x.end()
    10 #define pb push_back
    11 #define mp make_pair
    12 #define MAXN 100005
    13 #define fi first
    14 #define se second
    15 #define SZ(x) ((int)x.size())
    16 using namespace std;
    17 typedef long long ll;
    18 typedef vector<int> vi;
    19 typedef pair<int, int> pii;
    20 const int INF = 1 << 30;
    21 const int p = 1000000009;
    22 int lowbit(int x){ return x & (-x);}
    23 int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}
    24 
    25 int a[MAXN];
    26 
    27 int main(){
    28     int t;
    29     scanf("%d", &t);
    30     rep(times, 1, t){
    31         int n, s;
    32         scanf("%d%d", &n, &s);
    33         rep(i, 1, n) scanf("%d", &a[i]);
    34         int sum = 0, maxx = 0, ans = 0;
    35         rep(i, 1, n){
    36             sum += a[i];
    37             if(a[i] > maxx){
    38                 maxx = a[i];
    39                 ans = i;
    40             }
    41             if(sum > s) break;
    42         }
    43         if(sum <= s) puts("0");
    44         else printf("%d
    ", ans);
    45     }
    46     return 0;
    47 }
    View Code-B

    C.Stack of Presents

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 #include <cstring>
     5 #include <vector>
     6 #define rep(x, l, r) for(int x = l; x <= r; x++)
     7 #define repd(x, r, l) for(int x = r; x >= l; x--)
     8 #define clr(x, y) memset(x, y, sizeof(x))
     9 #define all(x) x.begin(), x.end()
    10 #define pb push_back
    11 #define mp make_pair
    12 #define MAXN
    13 #define fi first
    14 #define se second
    15 #define SZ(x) ((int)x.size())
    16 using namespace std;
    17 typedef long long ll;
    18 typedef vector<int> vi;
    19 typedef pair<int, int> pii;
    20 const int INF = 1 << 30;
    21 const int p = 1000000009;
    22 int lowbit(int x){ return x & (-x);}
    23 int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}
    24 
    25 int main(){
    26     int t;
    27     scanf("%d", &t);
    28     rep(times, 1, t){
    29         int n;
    30         scanf("%d", &n);
    31         ll s1 = 0, s2 = 0;
    32         rep(i, 1, n){
    33             ll x;
    34             scanf("%lld", &x);
    35             s1 += x;
    36             s2 ^= x;
    37         }
    38         s2 <<= 1;
    39         ll ans = 0;
    40         for(int i = 0; s1 != s2; i++){
    41             if((s1 & 1) ^ (s2 & 1)){
    42                 s1 += 1;
    43                 s2 ^= 2;
    44                 ans += 1ll << i;
    45             }
    46             s1 >>= 1;
    47             s2 >>= 1;
    48         }
    49         printf("1
    %lld
    ", ans);
    50     }
    51     return 0;
    52 }
    View Code-C

    D.Santa's Bot

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 #include <cstring>
     5 #include <vector>
     6 #define rep(x, l, r) for(int x = l; x <= r; x++)
     7 #define repd(x, r, l) for(int x = r; x >= l; x--)
     8 #define clr(x, y) memset(x, y, sizeof(x))
     9 #define all(x) x.begin(), x.end()
    10 #define pb push_back
    11 #define mp make_pair
    12 #define MAXN 1000005
    13 #define fi first
    14 #define se second
    15 #define SZ(x) ((int)x.size())
    16 using namespace std;
    17 typedef long long ll;
    18 typedef vector<int> vi;
    19 typedef pair<int, int> pii;
    20 const int INF = 1 << 30;
    21 const int p = 998244353;
    22 int lowbit(int x){ return x & (-x);}
    23 int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}
    24 
    25 vi a[MAXN];
    26 int inv[MAXN], id[MAXN], sum[MAXN];
    27 
    28 int main(){
    29     int n;
    30     scanf("%d", &n);
    31     inv[1] = 1;
    32     rep(i, 2, 1000000) inv[i] = 1ll * (p - p / i) * inv[p % i] % p;
    33     rep(i, 1, n){
    34         int k;
    35         scanf("%d", &k);
    36         rep(j, 1, k){
    37             int x;
    38             scanf("%d", &x);
    39             a[i].pb(x);
    40             if(id[x] != i){
    41                 sum[x]++;
    42                 id[x] = i;
    43             }
    44         }
    45     }
    46     int ans = 0;
    47     rep(i, 1, n){
    48         rep(j, 0, SZ(a[i]) - 1){
    49             ans = (ans + 1ll * sum[a[i][j]] * inv[n] % p * inv[n] % p * inv[SZ(a[i])] % p) % p;
    50         }
    51     }
    52     printf("%d
    ", ans);
    53     return 0;
    54 }
    View Code-D
  • 相关阅读:
    读取ClassPath下resource文件的正确姿势
    动画展现十大经典排序算法(附Java代码)
    定量度量程序复杂度的McCabe方法
    从一个例子入门Mysql储存过程
    从源码看Spring Security之采坑笔记(Spring Boot篇)
    函数传递参数的本质
    main函数是必须的吗
    变量存储与长度
    C语言与汇编衔接1
    关于function和task的说明
  • 原文地址:https://www.cnblogs.com/nblyz2003/p/12168346.html
Copyright © 2020-2023  润新知