Welcome To Ke_scholar's Blog|

Ke_scholar

园龄:2年2个月粉丝:30关注:10

2023-08-18 01:57阅读: 6评论: 0推荐: 0

SMU Summer 2023 Contest Round 13

SMU Summer 2023 Contest Round 13

A. Review Site

我们总是可以把差评放到另一个服务器,好评和中立放另一个,这样最多投票数就是好评与中立数

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<int> r(n);
int ans = 0;
for (auto &i : r) {
cin >> i;
ans += (i != 2);
}
cout << ans << '\n';
}
return 0;
}

B. GCD Length

就是去凑\(a\)\(b\)都有\(c\)个相同因子就行,我这里凑得相同因子是\(11\),然后\(a\)一直乘\(2\)到对应位数,\(b\)一直乘\(3\)到对应位数

#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> PII;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int a, b, c;
cin >> a >> b >> c;
int g = 0, cc = c;
while (cc > 0) {
g = g * 10 + 1;
cc--;
}
if (a == b && a == c) {
cout << g << ' ' << g << '\n';
} else {
int a1 = pow(10, a - 1), b1 = pow(10, b - 1), g1 = g, g2 = g;
while (g1 < a1) g1 *= 2;
while (g2 < b1) g2 *= 3;
cout << g1 << ' ' << g2 << '\n';
}
}
return 0;
}

C. Yet Another Card Deck

因为\(a_i\)最多只有\(50\),所以我们可以用一个桶去记录每个数第一次的位置,然后将某个数提前的时候就将这个数前面位置的都往后挪一位

#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,q;
cin >> n >> q;
vector<i64> a(n + 1);
vector<int> t(55);
for(int i = 1;i <= n;i ++){
cin >> a[i];
if(!t[a[i]]) t[a[i]] = i;
}
while(q--){
int x;
cin >> x;
cout << t[x] << ' ';
for(int i = 1;i <= 50;i ++){
if(i != x && t[i] < t[x])
t[i]++;
}
t[x] = 1;
}
return 0;
}

D. Min Cost String

观察第一个样例我们得出按照a ab ac ad b bc bd…这样去构造一个循环字符串即可满足要求

#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
cin >> n >> k;
string ans = "";
for(int i = 'a';i < k + 'a';i ++){
ans += i;
for(int j = i + 1;j < k + 'a';j ++){
ans += i, ans += j;
}
}
for(int i = 0;i < n;i ++)
cout << ans[i % ans.size()];
cout << '\n';
return 0;
}

本文作者:Ke_scholar

本文链接:https://www.cnblogs.com/Kescholar/p/17639318.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Ke_scholar  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起