第二届全国中医药院校程序设计竞赛

Posted wstong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第二届全国中医药院校程序设计竞赛相关的知识,希望对你有一定的参考价值。

Problem  A 篮球队选拔 排序 
Problem  B 不存在的泳池 水题
Problem  C 调酒壶里的酸奶 深搜
Problem  D 过分的谜题 模拟
Problem  E 小C的数学问题 单调栈 
Problem  F fps游戏 数学题
Problem  G 闪闪发光 水题 
Problem  H 流连人间的苏苏 水题 
Problem  I 奔赴云南 水题 
Problem  J TCMPC进阶之路 水题 

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int maxn = 200005;
 5 int a[maxn], b[maxn], c[maxn];
 6 int main() {
 7     int t; scanf("%d",&t);
 8     while (t--) {
 9         int n; scanf("%d",&n);
10         for (int i = 1; i <= 2*n; i++) scanf("%d",&a[i]);
11         for (int i = 1; i <= 2*n; i++) scanf("%d",&b[i]);
12         for (int i = 1; i <= 2*n; i++) c[i] = a[i]+b[i];
13         sort(c+1,c+1+2*n);
14         if (c[n] < c[n+1]) printf("Cheat
");
15         else printf("Fail
");
16     }
17     return 0;
18 }
Problem A 篮球队选拔

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main() {
 4     int a, b;
 5     while (~scanf("%d%d",&a,&b)) {
 6         int a2, a3, b2, b3, tmp;
 7         a2 = a3 = b2 = b3 = 0;
 8         tmp = a;
 9         while (tmp % 2 == 0) tmp /= 2, a2++;
10         tmp = a;
11         while (tmp % 3 == 0) tmp /= 3, a3++;
12         tmp = b;
13         while (tmp % 2 == 0) tmp /= 2, b2++;
14         tmp = b;
15         while (tmp % 3 == 0) tmp /= 3, b3++;
16         if (a2 > b2)
17             for (int i = 1; i <= a2-b2; i++) a /= 2;
18         else if (b2 > a2)
19             for (int i = 1; i <= b2-a2; i++) b /= 2;
20         if (a3 > b3)
21             for (int i = 1; i <= a3-b3; i++) a /= 3;
22         else if (b3 > a3)
23             for (int i = 1; i <= b3-a3; i++) b /= 3;
24         if (a != b) puts("-1");
25         else printf("%d
",abs(a2-b2)+abs(a3-b3));
26     }
27     return 0;
28 }
Problem B 不存在的泳池

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int a, b, c, ans;
 4 const int inf = 0x3f3f3f3f;
 5 bool vis[105][105];
 6 void dfs(int na, int nb, int cur) {
 7     if (vis[na][nb]) return;
 8     if (cur > ans) return;
 9     if (na == c || nb == c) {
10         ans = min(ans,cur);
11         return;
12     }
13     vis[na][nb] = true;
14     dfs(a,nb,cur+1);
15     dfs(na,b,cur+1);
16     dfs(0,nb,cur+1);
17     dfs(na,0,cur+1);
18     dfs(max(0,na-(b-nb)),min(b,na+nb),cur+1);
19     dfs(min(a,nb+na),max(0,nb-(a-na)),cur+1);
20     vis[na][nb] = false;
21 }
22 int main() {
23     while (scanf("%d%d%d",&a,&b,&c) != EOF) {
24         if (c%__gcd(a,b) != 0) {
25             puts("impossible");
26             continue;
27         }
28         memset(vis,0,sizeof(vis));
29         ans = inf;
30         dfs(0,0,0);
31         printf("%d
",ans);
32     }
33     return 0;
34 }
Problem C 调酒壶里的酸奶

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int a[10005];
 4 void get(int n) {
 5     int pos = 1; pos += 1;
 6     int ans = 1;
 7     while (pos != 1) {
 8         if (pos <= n) pos += pos, ans++;
 9         else pos -= 2*n-pos+1, ans++;
10     }
11     a[n] = ans;
12 }
13 int main() {
14     for (int i = 1; i <= 10000; i++)
15         get(i);
16     int n;
17     while (scanf("%d",&n) != EOF) {
18         printf("%d
",a[n]);
19     }
20     return 0;
21 }
Problem D 过分的谜题

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int maxn = 1e5+5;
 5 ll a[maxn], sum[maxn];
 6 int L[maxn], R[maxn];
 7 int main() {
 8     int n; scanf("%d",&n);
 9     for (int i = 1; i <= n; i++) {
10         scanf("%lld",&a[i]);
11         sum[i] = sum[i-1]+a[i];
12     }
13     for (int i = 1; i <= n; i++) {
14         int l = i;
15         while (a[i] <= a[l-1] && l > 1) l = L[l-1];
16         L[i] = l;
17     }
18     for (int i = n; i >= 1; i--) {
19         int r = i;
20         while (a[i] <= a[r+1] && r < n) r = R[r+1];
21         R[i] = r;
22     }
23     ll ans = -1;
24     int l, r;
25     for (int i = 1; i <= n; i++) {
26         ll val =  (sum[R[i]]-sum[L[i]-1])*a[i];
27         if (ans < val) {
28             ans = val;
29             l = L[i];
30             r = R[i];
31         }
32     }
33     printf("%lld
",ans);
34     printf("%d %d
",l,r);
35     return 0;
36 }
Problem E 小C的数学问题

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 const double pi = acos(-1);
 4 int main() {
 5     int d, r, c; double a;
 6     scanf("%d%d%d%lf",&d,&r,&c,&a);
 7     double v = atan(1.0*r/d)*180/pi;
 8     int num = v/a + 1;
 9     cout << max(0,c-num) << endl;
10     return 0;
11 }
Problem F fps游戏

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int maxn = 1e6+1000;
 5 ll a[maxn];
 6 int main() {
 7     int n;
 8     while (cin >> n) {
 9         memset(a,0,sizeof(a));
10         for (int i = 1; i <= n; i++) {
11             int x; scanf("%d",&x);
12             a[x]++;
13         }
14         ll ans = 0;
15         for (int i = 0; i <= 1000500; i++) {
16             a[i+1] += a[i]/2;
17             if (a[i] % 2 == 1) ans++;
18         }
19         printf("%lld
",ans);
20     }
21     return 0;
22 }
Problem G 闪闪发光

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int maxn = 1010;
 5 int n, d;
 6 bool tree[maxn];
 7 void print() {
 8     int l = 0;
 9     vector<int> L, R;
10     for (int i = 1; i <= n+5; i++) {
11         if (tree[i] && l == 0) l = i;
12         if (!tree[i] && l != 0) {
13             L.push_back(l);
14             R.push_back(i-1);
15             l = 0;
16         }
17     }
18     printf("[%d,%d]",L[0],R[0]);
19     for (int i = 1; i < L.size(); i++)
20         printf(",[%d,%d]",L[i],R[i]);
21     printf("
");
22 }
23 int main() {
24     scanf("%d%d",&n,&d);
25     while (d--) {
26         int l, r; scanf("%d%d",&l,&r);
27         for (int i = l; i <= r; i++) tree[i] = true;
28         print();
29     }
30     return 0;
31 }
Problem H 流连人间的苏苏

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main() {
 4     string s; int t1, t2;
 5     while (cin >> s >> t1 >> t2) {
 6         t1 = t1/100*60 + t1%100;
 7         t2 = t2/100*60 + t2%100;
 8         printf("%s to Kunming: %02d:%02d
",s.c_str(),(t2-t1)/60,(t2-t1)%60);
 9     }
10     return 0;
11 }
Problem I 奔赴云南

 

技术图片
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main() {
 4     int t; scanf("%d",&t);
 5     while (t--) {
 6         int n; scanf("%d",&n);
 7         printf("%d
",n*(n+1)/2);
 8     }
 9     return 0;
10 }
Problem J TCMPC进阶之路

 

以上是关于第二届全国中医药院校程序设计竞赛的主要内容,如果未能解决你的问题,请参考以下文章

第三届全国中医药院校大学生程序设计竞赛题解

第五届全国中医药院校大学生程序设计竞赛重现赛——题解

2022年全国职业院校技能大赛(中职组)网络安全竞赛试题解析

复盘之如何介绍你的ACM经历

2021年全国职业院校技能大赛(中职组)网络安全竞赛第四套试题A模块解析(超级详细)

2022年全国职业院校技能大赛(中职组)网络安全竞赛试题A模块