2026-7-31代码源模拟赛-2赛后总结
模拟赛总算结束了,我又来写总结了。
比赛概述+难点分析:
- 本场比赛共6题。
- 本场比赛时长共4小时。
- T1,T2,T3,T5较简单,T4较难
(我当时调了1个小时) ,T6难度尚可 (没做完) 。
题目分析
T1 美味的辣酱
原题链接
这题不需要动脑子,直接上代码:
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| #include<bits/stdc++.h> using namespace std; int q,x; int main(){ cin >> q; while(q--){ cin >> x; if(x<4){ cout << "MILD\n"; }else if(x>=4&&x<7){ cout << "MEDIUM\n"; }else{ cout << "HOT\n"; } } return 0; }
|
T2 对决游戏
原题链接
emm…这题有点意思, 但是我当时卡了二十分钟
其实这题只需要总结几个赢的条件。注意一定要总结全!
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| #include<bits/stdc++.h> using namespace std; int q,a,b,c; int main(){ cin >> q; while(q--){ cin >> a >> b >> c; if(b+c<a){ cout << "YES\n"; }else if(abs(b-c)<a){ cout << "YES\n"; }else{ cout << "NO\n"; } } return 0; }
|
T3 硬币兑换
原题链接
分析:因为1枚金币可以兑换5枚银币,5枚银币可以兑换1枚金币;所以我们可以假设金币价值为5,银币价值为1。因为兑换时总价值不变,同时丢弃一枚金币和银币总价值就会减少6,可以先判断原来的总价值 p1 和兑换后的总价值 p2 ,如果 p1-p2(易得p1>=p2)%6!=0 就直接输出”No\n”。
话不多说,直接上代码。
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #include<bits/stdc++.h> using namespace std; typedef long long ll; ll q,a,b,aa,bb; int main(){ cin >> q; while(q--){ cin >> a >> b >> aa >> bb; ll p1=5*a+b,p2=5*aa+bb; if(p1<p2){ cout << "No\n"; continue; } if((p1-p2)%6!=0){ cout << "No\n"; continue; } ll jian=(p1-p2)/6; if(aa+jian>=0&&bb+jian>=0){ cout << "Yes\n"; }else{ cout << "No\n"; } } return 0; }
|
T4 追逐大作战
原题链接
就是这题花了我一个小时的宝贵时间!!!不然我T6就做出来了!!!
分析:
C++
T5 手链修复
原题链接
分析:假设两个原来的字符串和两个反转后的字符串分别为s1,s2,r1,r2;它们一共有四种组合方式:{s1,s2},{s1,r2},{r1,s2},{r1,r2};再写一个check()函数检验这是种组合方式能否被分成两个一模一样的字符串。
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #include<bits/stdc++.h> using namespace std; int q; string s1,s2; bool check(string t1,string t2){ bool flag=true; string tmp=t1+t2; int len=tmp.length(),m=len/2; for(int i=0;i<m;i++){ if(tmp[i]!=tmp[i+m]) flag=false; } return flag; } int main(){ cin >> q; while(q--){ cin >> s1 >> s2; if((s1.length()+s2.length())%2!=0){ cout << "NO\n"; continue; } string r1=s1,r2=s2; reverse(r1.begin(),r1.end()); reverse(r2.begin(),r2.end()); if(check(s1,s2)||check(s1,r2)||check(r1,s2)||check(r1,r2)){ cout << "YES\n"; }else{ cout << "NO\n"; } } return 0; }
|
T6 六进制能量果
原题链接
分析:因为输入的是一串六进制数,所以要先把它们转成十进制作乘法再转回六进制,最后统计一下就行了。
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| #include<bits/stdc++.h> using namespace std; int n,x,t[200005],tt[200005]; int main(){ cin >> n >> x; for(int i=1;i<=n;i++){ int y; cin >> y; int v=0,d=1; while(y){ v+=(y%10)*d; d*=6; y/=10; } t[i]=t[i-1]; while(!(v%2)){ v/=2; t[i]++; } tt[i]=tt[i-1]; while(!(v%3)){ v/=3; tt[i]++; } } int l=1; long long ans=0; for(int i=1;i<=n;i++){ while(l<=n&&(t[l]-t[i-1]<x||tt[l]-tt[i-1]<x)){ l++; } ans+=n-l+1; } cout << ans; return 0; }
|