A - Anti-Adjacency
签.
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 int n, k; 7 while (scanf("%d%d", &n, &k) != EOF) 8 { 9 int remind = (n + 1) / 2; 10 puts(k <= remind ? "YES" : "NO"); 11 } 12 return 0; 13 }
B - Path
签.
#include <bits/stdc++.h> using namespace std; int x, y, Max; vector <int> G[5]; void DFS(int u, int fa, int deep) { Max = max(Max, deep); for (auto v : G[u]) if (v != fa) DFS(v, u, deep + 1); } int main() { while (scanf("%d%d", &x, &y) != EOF) { for (int i = 1; i <= 4; ++i) G[i].clear(); G[x].push_back(y); G[y].push_back(x); for (int i = 1; i <= 2; ++i) { scanf("%d%d", &x, &y); G[x].push_back(y); G[y].push_back(x); } Max = 0; DFS(1, 1, 1); puts(Max == 4 ? "YES" : "NO"); } return 0; }
C - When I hit my pocket...
签.
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 #define ll long long 5 int k, a, b; 6 7 int main() 8 { 9 while (scanf("%d%d%d", &k, &a, &b) != EOF) 10 { 11 if (a >= (b - 2) || k < a) printf("%d\n", k + 1); 12 else 13 { 14 k -= a - 1; 15 int Loop = k / 2; 16 if (Loop == 0) printf("%d\n", a + k % 2); 17 else printf("%lld\n", 1ll * b + 1ll * (Loop - 1) * (b - a) + k % 2); 18 } 19 } 20 return 0; 21 }
原文地址:https://www.cnblogs.com/Dup4/p/10358313.html
时间: 2024-11-09 17:15:13