标签:else min long sizeof int .com algorithm ons 最小
这场怎么都是异或啊qwq。。。
直接判断奇偶性
#include<cstdio> #include<cstring> #include<algorithm> #define int long long using namespace std; const int MAXN = 2 * 1e6 + 10, INF = 1e9 + 10, B = 63; 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; } main() { #ifdef WIN32 //freopen("a.in", "r", stdin); #endif int N = read(); puts(N & 1 ? "Ehab" : "Mahmoud"); }
维护出每个graph的最小值,输出即可,我咋还开了个map
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<map> #define int long long using namespace std; const int MAXN = 2 * 1e6 + 10, INF = 1e9 + 10, B = 63; 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, G, M; string s[MAXN]; int val[MAXN], minval[MAXN]; map<string, int> ID; main() { #ifdef WIN32 //freopen("a.in", "r", stdin); #endif memset(minval, 0x3f, sizeof(minval)); N = read(); G = read(); M = read(); for(int i = 1; i <= N; i++) cin >> s[i]; //cout << s << endl; for(int i = 1; i <= N; i++) val[i] = read(); for(int i = 1; i <= G; i++) { int num = read(); for(int j = 1; j <= num; j++) { int x = read(); ID[s[x]] = i; } } for(int i = 1; i <= N; i++) minval[ID[s[i]]] = min(minval[ID[s[i]]], val[i]); //for(int i = 1; i <= N; i++) printf("%d ", ID[s[i]]); puts("***"); //for(int i = 1; i <= N; i++) printf("%d ", minval[ID[s[i]]]); puts("***"); int ans = 0; string x; for(int i = 1; i <= M; i++) { cin >> x; ans += minval[ID[x]]; } printf("%I64d", ans); }
我的构造思路比较奇葩,大概长这样。。
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<map> using namespace std; const int MAXN = 2 * 1e6 + 10, INF = 1e9 + 10, B = 63; 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; } main() { #ifdef WIN32 //freopen("a.in", "r", stdin); #endif int N = read(); if(N == 2 || N == 3 || N == 4 || N == 5) printf("-1\n"); else { printf("1 2\n"); printf("1 3\n"); printf("1 4\n"); for(int i = 5; i <= N; i++) printf("3 %d\n", i); } for(int i = 1; i <= N - 1; i++) printf("%d %d\n", i, i + 1); }
打表后强上oeis
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<map> #define int long long using namespace std; 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; } map<int, int> ans; int B(int x) { if(ans[x] ) return ans[x]; if(x & 1) return ans[x] = 2 * B(x / 2) + (x / 2) + 1; else return ans[x] = 2 * B(x / 2) + x / 2; } main() { #ifdef WIN32 //freopen("a.in", "r", stdin); #endif ans[1] = 1; int N = read(); printf("%I64d", B(N - 1)); }
Codeforces Round #473 (Div. 2)
标签:else min long sizeof int .com algorithm ons 最小
原文地址:https://www.cnblogs.com/zwfymqz/p/9190667.html