2021寒假训练(十)
| 题号 | A | B | C | D | E | F | G | H |
| AC | √ | √ | √ | √ |
#include<list> #include<string.h> #include<cstdio> #include<iostream> #include<algorithm> #include<cmath> #include<string> #include<cstring> #include<vector> #include<map> #include<deque> #include<stack> #include<queue> #include<set> #include<iomanip> #include<cstdlib> #include<stdexcept> #include<fstream> #include<iterator> using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn = 1e3 + 10; const int inf = 0x3f3f3f3f; const int Base =131; const ll INF = 1ll << 62; //const double PI = acos(-1); const double eps = 1e-7; const int mod = 1e9+7; #define speed {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); } int SG[maxn],vis[maxn],m; int getSG(int n) { if(SG[n]!=-1)return SG[n]; if(m>n)return SG[n]=0; memset(vis,0,sizeof vis); for(int i=m;i<=n;i++) vis[getSG(i-m)^getSG(n-i)]=1; for(int i=0;i<=n;i++) if(vis[i]==0) { SG[n]=i; break; } return SG[n]; } int main() { int T,Case=0; scanf("%d",&T); while(T--) { int n; scanf("%d %d",&n,&m); if(m>n) { printf("Case #%d: abcdxyzk\n",++Case); continue; } memset(SG,-1,sizeof SG); n-=m; for(int i=0;i<=n;i++) SG[i]=getSG(i); if(!SG[n])printf("Case #%d: aekdycoin\n",++Case); else printf("Case #%d: abcdxyzk\n",++Case); } system("pause"); return 0; }
#include <string.h> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdexcept> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 1e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1000000007; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } int flag; void dfs(int n, int d){ if(n == 0){ flag = 1; return; }else if(n < 0){ return; } for(int i = 0; i <= n; i++){ int m = n - (i * 10 + d); dfs(m, d); } } signed main(){ int T = rd(); while(T--){ int q = rd(); int d = rd(); while(q--){ flag = 0; int n = rd(); if(n >= d * 10 || n % 10 == d)printf("YES\n"); else{ dfs(n, d); if(flag == 1)printf("YES\n"); else printf("NO\n"); } } } //system("pause"); return 0; }
#include <string.h> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdexcept> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long // #define int long long const int maxn = 1e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1000000007; // #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } struct Node{ double x, y; }v[maxn]; struct Edge{ int u, v; double w; Edge(){} Edge(int u, int v, double w):u(u),v(v),w(w){} }e[maxn]; bool cmp(Edge a, Edge b){ return a.w < b.w; } double getDis(double x1, double y1, double x2, double y2){ return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } int fa[maxn], cnt; void init(){ for(int i = 0; i < maxn; i++)fa[i] = i; } int Find(int x){ return x == fa[x] ? x : fa[x] = Find(fa[x]); } void Union(int x, int y){ int fx = Find(x); fa[x] = Find(y); } double kruskal(int s, int p){ init(); int count = 0; for(int i = 0; i < cnt; i++){ int x = Find(e[i].u); int y = Find(e[i].v); if(x == y) continue; Union(x, y); count++; if(count == p - s){ return e[i].w; } } return 0; } signed main(){ int T; scanf("%d", &T); while(T--){ int s, p; scanf("%d %d", &s, &p); for(int i = 0; i < p; i++){ scanf("%lf %lf", &v[i].x, &v[i].y); } cnt = 0; for(int i = 0; i < p; i++){ for(int j = i + 1; j < p; j++){ double dis = getDis(v[i].x, v[i].y, v[j].x, v[j].y); e[cnt++] = Edge(i, j, dis); } } sort(e, e + cnt, cmp); printf("%.2f\n", kruskal(s, p)); } system("pause"); return 0; }
#include <string.h> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <stdexcept> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; #define ll long long #define int long long const int maxn = 1e5 + 10; const int inf = 0x3f3f3f3f; const int Base = 131; const ll INF = 1ll << 62; const double PI = acos(-1); const double eps = 1e-7; const int mod = 1000000007; #define PI acos(-1) #define mem(a, b) memset(a, b, sizeof(a)) #define speed { ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);} // inline int gcd(int a, int b) { // while (b ^= a ^= b ^= a %= b); // return a; // } inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } long long fastPower(long long base, long long power) { long long result = 1; while (power > 0) { if (power & 1) result = result * base % mod; power >>= 1; base = (base * base) % mod; } return result; } inline ll rd() { ll s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } int a[maxn],vis[maxn << 1]; signed main(){ int T = rd(); while(T--){ int cnt = 0; int n = rd(); mem(vis, 0); for(int i = 0; i < n; i++){ int m =rd(); if(vis[m] == 0){ cnt++; vis[m] = 1; }else{ m++; if(vis[m] == 0){ cnt++; vis[m] = 1; } } } printf("%lld\n",cnt); } //system("pause"); return 0; }

浙公网安备 33010602011771号