没想到平成年代最后一场cf居然是手速场,幸好拿了个小号娱乐不然掉分预定 (逃
A:
傻题。
1 /* basic header */ 2 #include <iostream> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <string> 6 #include <cstring> 7 #include <cmath> 8 #include <cstdint> 9 #include <climits> 10 #include <float.h> 11 /* STL */ 12 #include <vector> 13 #include <set> 14 #include <map> 15 #include <queue> 16 #include <stack> 17 #include <algorithm> 18 #include <array> 19 #include <iterator> 20 /* define */ 21 #define ll long long 22 #define dou double 23 #define pb emplace_back 24 #define mp make_pair 25 #define fir first 26 #define sec second 27 #define sot(a,b) sort(a+1,a+1+b) 28 #define rep1(i,a,b) for(int i=a;i<=b;++i) 29 #define rep0(i,a,b) for(int i=a;i<b;++i) 30 #define repa(i,a) for(auto &i:a) 31 #define eps 1e-8 32 #define int_inf 0x3f3f3f3f 33 #define ll_inf 0x7f7f7f7f7f7f7f7f 34 #define lson curPos<<1 35 #define rson curPos<<1|1 36 /* namespace */ 37 using namespace std; 38 /* header end */ 39 40 const int maxn = 1e2 + 10; 41 int n, m, r, minn = 2000, maxx = 0; 42 43 int main() 44 { 45 scanf("%d%d%d", &n, &m, &r); 46 rep1(i, 1, n) 47 { 48 int x; scanf("%d", &x); minn = min(minn, x); 49 } 50 rep1(i, 1, m) 51 { 52 int x; scanf("%d", &x); maxx = max(maxx, x); 53 } 54 if (maxx > minn) printf("%d\n", maxx * (r / minn) + r % minn); 55 else printf("%d\n", r); 56 return 0; 57 }
B:
乍一看以为要搜,其实根本不需要,n^2填进去判断就完事了 (看通过人数就能猜到根本不用搜。
至于为什么可以这样,是因为跟紧密填充相关吗?
1 /* basic header */ 2 #include <iostream> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <string> 6 #include <cstring> 7 #include <cmath> 8 #include <cstdint> 9 #include <climits> 10 #include <float.h> 11 /* STL */ 12 #include <vector> 13 #include <set> 14 #include <map> 15 #include <queue> 16 #include <stack> 17 #include <algorithm> 18 #include <array> 19 #include <iterator> 20 /* define */ 21 #define ll long long 22 #define dou double 23 #define pb emplace_back 24 #define mp make_pair 25 #define fir first 26 #define sec second 27 #define sot(a,b) sort(a+1,a+1+b) 28 #define rep1(i,a,b) for(int i=a;i<=b;++i) 29 #define rep0(i,a,b) for(int i=a;i<b;++i) 30 #define repa(i,a) for(auto &i:a) 31 #define eps 1e-8 32 #define int_inf 0x3f3f3f3f 33 #define ll_inf 0x7f7f7f7f7f7f7f7f 34 #define lson curPos<<1 35 #define rson curPos<<1|1 36 /* namespace */ 37 using namespace std; 38 /* header end */ 39 40 const int maxn = 55; 41 int a[maxn][maxn], n, solved = 0; 42 char s[maxn]; 43 44 int check() 45 { 46 rep1(i, 1, n) 47 rep1(j, 1, n) 48 if (!a[i][j]) return 0; 49 return 1; 50 } 51 52 int putable(int x, int y) 53 { 54 if (x == 1 || x == n || y == 1 || y == n) return 0; 55 if (a[x - 1][y] || a[x + 1][y] || a[x][y - 1] || a[x][y + 1] || a[x][y]) return 0; 56 return 1; 57 } 58 59 int main() 60 { 61 scanf("%d", &n); 62 rep1(i, 1, n) 63 { 64 scanf("%s", s + 1); 65 rep1(j, 1, n) 66 if (s[j] == ‘#‘) a[i][j] = 1; else a[i][j] = 0; 67 } 68 rep1(i, 2, n - 1) 69 { 70 rep1(j, 2, n - 1) 71 if (putable(i, j)) 72 { 73 a[i - 1][j] = a[i + 1][j] = a[i][j - 1] = a[i][j + 1] = a[i][j] = 1; 74 } 75 } 76 if (check()) puts("YES"); 77 else puts("NO"); 78 return 0; 79 }
C:
2e5质数筛贪心就完事了,优先满足最近的质数,先塞2再塞1,也有大佬说不用筛。
1 /* basic header */ 2 #include <iostream> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <string> 6 #include <cstring> 7 #include <cmath> 8 #include <cstdint> 9 #include <climits> 10 #include <float.h> 11 /* STL */ 12 #include <vector> 13 #include <set> 14 #include <map> 15 #include <queue> 16 #include <stack> 17 #include <algorithm> 18 #include <array> 19 #include <iterator> 20 /* define */ 21 #define ll long long 22 #define dou double 23 #define pb emplace_back 24 #define mp make_pair 25 #define fir first 26 #define sec second 27 #define sot(a,b) sort(a+1,a+1+b) 28 #define rep1(i,a,b) for(int i=a;i<=b;++i) 29 #define rep0(i,a,b) for(int i=a;i<b;++i) 30 #define repa(i,a) for(auto &i:a) 31 #define eps 1e-8 32 #define int_inf 0x3f3f3f3f 33 #define ll_inf 0x7f7f7f7f7f7f7f7f 34 #define lson curPos<<1 35 #define rson curPos<<1|1 36 /* namespace */ 37 using namespace std; 38 /* header end */ 39 40 const int maxn = 2e5 + 10; 41 int c1 = 0, c2 = 0, n, prime[maxn], p = 1, tot; 42 vector<int>ans; 43 44 bool valid[maxn]; 45 void getPrime(int n, int &tot, int ans[maxn]) 46 { 47 tot = 0; 48 memset(valid, 1, sizeof(valid)); 49 for (int i = 2; i <= n; i++) 50 { 51 if (valid[i]) ans[++tot] = i; 52 for (int j = 1; (j <= tot) && (i * ans[j] <= n); j++) 53 { 54 valid[i * ans[j]] = false; 55 if (i % ans[j] == 0) break; 56 } 57 } 58 } 59 60 int main() 61 { 62 getPrime(2e5, tot, prime); 63 ans.clear(); 64 scanf("%d", &n); 65 rep1(i, 1, n) 66 { 67 int x; scanf("%d", &x); 68 if (x & 1) c1++; else c2++; 69 } 70 int curr = 0; 71 while (c1 || c2) 72 { 73 if (prime[p] - curr > 2 && c2) 74 { 75 ans.pb(2); c2--; curr += 2; 76 } 77 else if (prime[p] - curr == 2 && c2) 78 { 79 ans.pb(2); c2--; p++; curr += 2; 80 } 81 else if (prime[p] - curr == 1 && c1) 82 { 83 ans.pb(1); c1--; p++; curr += 1; 84 } 85 else 86 { 87 if (c2) 88 { 89 ans.pb(2); c2--; curr += 2; 90 } 91 else if (c1) 92 { 93 ans.pb(1); c1--; curr += 1; 94 } 95 } 96 } 97 for (auto i : ans) printf("%d ", i); 98 return 0; 99 }
D:
把全场人卡死的dp,直到比赛结束都只有不到20个人过了,待补。
E:
看了一眼感觉其实比D简单(我口胡的),待补。
原文地址:https://www.cnblogs.com/JHSeng/p/10795255.html
时间: 2024-10-08 03:07:11