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 }

-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\n", ans);
45     }
46     return 0;
47 }

-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\n%lld\n", ans);
50     }
51     return 0;
52 }

-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\n", ans);
53     return 0;
54 }

-D

原文地址:https://www.cnblogs.com/nblyz2003/p/12168346.html

时间: 2024-08-22 16:40:58

Educational Codeforces Round 79做题记录的相关文章

Educational Codeforces Round 62 做题记录

A. 题解: 发现就是找前缀 max = i 的点的个数,暴力扫一遍 1 #include<bits/stdc++.h> 2 #define ll long long 3 #define pii pair<int,int> 4 #define mp(a,b) make_pair(a,b) 5 using namespace std; 6 #define maxn 10005 7 int n; 8 int a[maxn]; 9 int main() 10 { 11 scanf(&qu

Educational Codeforces Round 79 (Rated for Div. 2)

A. New Year Garland (CF 1279 A) 题目大意 给定红绿蓝三种颜色灯的数量,问能否摆成一排,使得相邻颜色不相同. 解题思路 植树问题.考虑数量最多为\(n\)的颜色的灯俩俩不相邻,那么其他颜色的灯的数量和要大于\(n-1\)即可,大过\(n-1\)的灯直接插到里面就好了. 神奇的代码 #include <bits/stdc++.h> #define MIN(a,b) ((((a)<(b)?(a):(b)))) #define MAX(a,b) ((((a)>

Educational Codeforces Round 79 D Santa&#39;s Bot

  被教育场 题意:先等概率选一个人,再从他想要礼物里等概率选一个,再独立于前两次选择,选一个人,他想要的礼物也被选中,则该组合有效,求组合有效的分数概率(模意义下) 玩一下两个样例应该就能出来知道咋算,虽然我第一个样例是跑了两重循环得出 7/8,拼凑起来才勉强理解的题意. 但知道咋算不一定会code啊. 我就是啊. 模拟了分数的加法乘法运算,通分约分,肯定要WA啊,因为到后面分子分母越来越大存不下. 但实际上,两个分数在某个模数意义下相加可以直接转化,即   x/y+u/v  == x*inv

Educational Codeforces Round 79 (Rated for Div. 2) D. Santa&#39;s Bot

链接: https://codeforces.com/contest/1279/problem/D 题意: Santa Claus has received letters from n different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the i-th kid asked Santa to give them one of

比赛记录[Educational Codeforces Round 79 (Rated for Div. 2)]

首先声明,这是本蒟蒻第一次打CF,也是第一次发博客,大佬勿喷 A                 B                 C              D              E               F 数学      贪心 N/A           N/A             N/A          N/A A. New Year Garland 由于第一次打CF,比赛节奏和心态调整不太好,加上英文题目难以理解(本蒟蒻英语太垃圾),在第一题上水了15分钟. 第

Codeforces Global Round 1 做题记录

A. 题解:快速幂 代码: 1 #include<bits/stdc++.h> 2 #define ll long long 3 #define maxn 100005 4 using namespace std; 5 const ll mod=2; 6 ll b,k; 7 ll a[maxn]; 8 ll fastpow(ll a,ll p) 9 { 10 ll ans=1; 11 while(p) 12 { 13 if(p&1)ans=ans*a%mod; 14 a=a*a%mod

Educational Codeforces Round 23 补题小结

昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; int x1,x2,yy1,y2,x,y; int main(){ scanf("%d%d%d%d%d%d&qu

Educational Codeforces Round 79 (Rated for Div. 2) C. Stack of Presents

链接: https://codeforces.com/contest/1279/problem/C 题意: Santa has to send presents to the kids. He has a large stack of n presents, numbered from 1 to n; the topmost present has number a1, the next present is a2, and so on; the bottom present has numbe

Educational Codeforces Round 21 A-E题题解

A题      ............太水就不说了,贴下代码 #include<string> #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<queue> #include<cstdio> using namespace std; int n,m; int m