Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)
来源:互联网 发布:centos更新python 编辑:程序博客网 时间:2024/04/29 01:33
A
#include <cstdio>#include <cmath>#include <cstring>#include <cctype>#include <sstream>#include <iostream>#include <algorithm>#include <queue>#include <stack>#include <vector>#include <string>#include <map>#include <set>#include <utility>using namespace std;#define LL long long#define mst(Arr, x)memset(Arr, x, sizeof(Arr));#define pb push_back#define mk make_pair#define REP(i, x, n)for(int i = x; i < n; ++i)const int qq = 1e5 + 10;const int INF = 1e9 + 10;int n;int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}int lcm(int a, int b){return a / gcd(a, b) * b;}int main(){LL a, b;scanf("%lld%lld", &a, &b);if(a >= b){printf("1\n");return 0;}for(int i = 2; ; ++i){a = a * 3LL;b = b * 2LL;if(a > b){printf("%d\n", i);return 0;}}return 0;}
B
對於每一個連通塊,都要求是一個完全字圖
也就是每一個節點的度數都等於這個連通塊頂點的個數 - 1
#include <cstdio>#include <cmath>#include <cstring>#include <cctype>#include <sstream>#include <iostream>#include <algorithm>#include <queue>#include <stack>#include <vector>#include <string>#include <map>#include <set>#include <utility>using namespace std;#define LL long long#define mst(Arr, x)memset(Arr, x, sizeof(Arr));#define pb push_back#define mk make_pair#define REP(i, x, n)for(int i = x; i < n; ++i)const int qq = 3e5 + 10;const int INF = 1e9 + 10;int n, m;int deg[qq];int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}int lcm(int a, int b){return a / gcd(a, b) * b;}int fa[qq];int Find(int x){return fa[x] == -1 ? x : fa[x] = Find(fa[x]);}queue<int> Q[qq];int main(){mst(fa, -1);mst(deg, 0);scanf("%d%d", &n, &m);for(int i = 0; i < m; ++i){int a, b;scanf("%d%d", &a, &b);deg[a]++, deg[b]++;int x = Find(a), y = Find(b);if(x != y)fa[y] = x;}for(int i = 1; i <= n; ++i){Q[Find(i)].push(i);}bool flag = true;for(int i = 1; i <= n; ++i){if(Q[i].size() == 0)continue;int k = Q[i].size() - 1;Q[i].pop();while(!Q[i].empty()){int v = Q[i].front();Q[i].pop();if(k != deg[v])flag = false;}}if(flag)printf("YES\n");elseprintf("NO\n");return 0;}
C
對於每一個假設第i個區間是NO, 假設這個區間的最右端是r, 讓str[r] = str[r - k + 1] 相等即可, 它不影響其他的連續區間
#include <cstdio>#include <cmath>#include <cstring>#include <cctype>#include <sstream>#include <iostream>#include <algorithm>#include <queue>#include <stack>#include <vector>#include <string>#include <map>#include <set>#include <utility>using namespace std;#define LL long long#define mst(Arr, x)memset(Arr, x, sizeof(Arr));#define pb push_back#define mk make_pair#define REP(i, x, n)for(int i = x; i < n; ++i)const int qq = 1e5 + 10;const int INF = 1e9 + 10;int n, k;int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}int lcm(int a, int b){return a / gcd(a, b) * b;}string str[105];string name[105];int num[105];string f;map<string, bool> mp;int main(){for(int i = 1; i <= 26; ++i)name[i] = 'A' + (i - 1);for(int i = 27; i <= 26*2; ++i){name[i] = name[i - 26] + "c";}cin >> n >> k;int p = 1;for(int i = 1; i < k; ++i)str[i] = name[p++];for(int i = k; i <= n; ++i){cin >> f;if(f == "YES"){str[i] = name[p++];}else{str[i] = str[i - k + 1];}}for(int i = 1; i <= n; ++i){if(str[i] == "")str[i] = name[p++];}for(int i = 1; i <= n; ++i)cout << str[i] << " ";return 0;}
0 0
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)
- 【解题报告】Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)
- Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) 题解(待续)
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A -- D
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A. Vicious Keyboard
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) B. Valued Keys
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) C. Voltage Keepsake
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) D. Volatile Kite
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)-C. Voltage Keepsake
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) ABCD
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)
- 【解题报告】Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)
- Codeforces Round #405 (rated, Div. 1, based on VK Cup 2017 Round 1) C. Bear and Company(DP)
- 深夜切题——Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)
- GMT单位及默认设置
- 一维数组写杨辉三角
- Linux的起源:从一个故事说起
- PHP array指定元素操作
- Rotrofit的简单使用
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1)
- 系统时间,OSTimeGet()和OSTimeSet()
- 树莓派----03_安装QT5
- 关系运算符——三个数排序
- 一般图最大匹配 带花树算法 模板
- IntelliJ IDEA 创建 hello world Java web Maven项目从头到尾都有图有真相2017版本
- 题目1123:采药
- 安装phpredis插件出现的问题
- 剑指offer: 丑数