CF 937
A
#include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vector<int>,greater<int>> que; get min const double eps = 1.0e-8; typedef pair<int, int> pairint; typedef long long ll; typedef unsigned long long ull; //const int maxn = 3e5 + 10; const int maxm = 300; const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}}; //priority_queue<int, vector<int>, less<int>> que; //next_permutation ll mod = 3e7; int num[606]; int main() { int n; cin >> n; int cur; for (int i = 1; i <= n; i++) { cin >> cur; num[cur] = 1; } int anser = 0; for (int i = 1; i <= 600; i++) { if (num[i]) { anser++; } } cout << anser << endl; return 0; }
B
#include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vector<int>,greater<int>> que; get min const double eps = 1.0e-8; typedef pair<int, int> pairint; typedef long long ll; typedef unsigned long long ull; //const int maxn = 3e5 + 10; const int maxm = 300; const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}}; //priority_queue<int, vector<int>, less<int>> que; //next_permutation ll mod = 3e7; ll p, y; bool check(ll now) { for (int i = 2; i * i <= now && i <= p; i++) { if (now % i == 0) { return 0; } } return 1; } int main() { cin >> p >> y; int flag = 0; for (int i = y; i >= p + 1; i--) { if (check(i)) { cout << i << endl; flag = 1; break; } } if (!flag) { cout << -1 << endl; } return 0; }
C
#include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vector<int>,greater<int>> que; get min const double eps = 1.0e-10; const double EPS = 1.0e-4; typedef pair<int, int> pairint; typedef long long ll; typedef unsigned long long ull; const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}}; //priority_queue<int, vector<int>, less<int>> que; //next_permutation int main() { double k, d, t; cin >> k >> d >> t; ll k1 = k; ll d1 = d; double ans = 0; if (k1 % d1 == 0) { printf("%.1f\n", t); return 0; } else { double bei = (long long)(k / d) + 1.0; //printf("bei: %.1f\n", bei); double xunhuan = bei * d; //printf("xunhuan: %.1f\n", xunhuan); double ximie = xunhuan - k; //printf("ximie: %.1f\n", ximie); double once = k + ximie / 2.0; //printf("once: %.1f\n", once); double bei2 = (long long)(t / once); //printf("bei2: %.1f\n", bei2); double remain = t - once * bei2; //printf("remain: %.1f\n", remain); ans += bei2 * xunhuan; //printf("ans: %.1f\n",ans); if (remain <= k) { ans += remain; } else { ans += k + (remain - k) * 2.0; } printf("%.1f\n", ans); } }
D
anser[i][j][0]表示偶数步能到达 [1]表示奇数部能到达
每个点最多访问两次
#include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vector<int>,greater<int>> que; get min const double eps = 1.0e-10; const double EPS = 1.0e-4; typedef pair<int, int> pairint; typedef long long ll; typedef unsigned long long ull; //const int maxn = 3e5 + 10; const int maxm = 300; const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}}; //priority_queue<int, vector<int>, less<int>> que; //next_permutation ll mod = 3e7; const int maxn = 200005; int anser[200005][3]; int visit[200005]; int flag = 0; int road[200005]; vector<int> pla[200005]; void dfs(int now, int x) { visit[now] = 1; anser[now][x % 2] = 1; road[x] = now; int to; int len = pla[now].size(); if (len == 0 && (x % 2 == 0)) { cout << "Win" << endl; for (int i = 1; i <= x; i++) { cout << road[i] << " "; } exit(0); } else { for (int i = 0; i < len; i++) { to = pla[now][i]; if (visit[to] == 1) { flag = 1; if (anser[to][(x + 1) % 2] == 1) { continue; } dfs(to, x + 1); } else { if (anser[to][(x + 1) % 2] == 1) { continue; } dfs(to, x + 1); } } } visit[now] = 2; } int main() { for (int i = 1; i <= 200000; i++) { for (int j = 0; j <= 1; j++) { anser[i][j] = -1; } } int n, m; int num; int to; cin >> n >> m; for (int i = 1; i <= n; i++) { scanf("%d", &num); for (int j = 1; j <= num; j++) { scanf("%d", &to); pla[i].pb(to); } } int aim; cin >> aim; dfs(aim, 1); if (flag) { cout << "Draw" << endl; return 0; } cout << "Lose" << endl; }