Japan Registry Services (JPRS) Programming Contest 2023 (AtCoder Beginner Contest 324) 赛后总结
1.HHKB Programming Contest 2023(AtCoder Beginner Contest 327) 赛后总结
2.Japan Registry Services (JPRS) Programming Contest 2023 (AtCoder Beginner Contest 324) 赛后总结
Japan Registry Services (JPRS) Programming Contest 2023 (AtCoder Beginner Contest 324) 赛后总结
可悲的是:我没来得及写题解。
Task A Same
秒切。
直接输入排一遍序再遍历即可。
#include <bits/stdc++.h>
using namespace std;
int n, a[101];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
for (int i = 2; i <= n; i++) {
if (a[i] != a[i - 1]) {
cout << "No";
return 0;
}
}
cout << "Yes";
return 0;
}
Task B 3-smooth Numbers
秒切。
直接暴力枚举。
注意:long long
#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
cin >> n;
unsigned long long sum1 = 1;
for (int x = 0; x <= 64; x++, sum1 *= 2) {
unsigned long long sum2 = 1;
for (int y = 0; y <= 40; y++, sum2 *= 3) {
if (sum1 * sum2 == n) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
return 0;
}
Task C Error Correction
赛时第一发出了一个很(好听的话)的问题,还好调出来了。
分
s.size() == t.size() && t == s
t.size() == s.size() - 1
t.size() == s.size() + 1
t.size() == s.size() && t != s
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
int n, ans, a[MAXN];
string s;
string str[MAXN];
bool check(int ind) {
if (str[ind].size() == s.size() && str[ind] == s) {
return 1;
}
if (str[ind].size() == s.size() + 1) {
int pos = -1;
for (int i = 0; i < s.size(); i++) {
if (s[i] != str[ind][i]) {
pos = i;
break;
}
}
if (pos == -1) {
return 1;
}
string s1 = s.substr(pos), s2 = str[ind].substr(pos + 1);
return (s1.size() == s2.size() && s1 == s2);
} else if (str[ind].size() == s.size() - 1) {
int pos = -1;
for (int i = 0; i < s.size() - 1; i++) {
if (s[i] != str[ind][i]) {
pos = i;
break;
}
}
if (pos == -1) {
return 1;
}
string s1 = s.substr(pos + 1), s2 = str[ind].substr(pos);
return (s1.size() == s2.size() && s1 == s2);
} else if (str[ind].size() == s.size()) {
int cnt = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] != str[ind][i]) {
cnt++;
}
}
return cnt == 1;
}
return 0;
}
int main() {
cin >> n >> s;
for (int i = 1; i <= n; i++) {
cin >> str[i];
if (check(i)) {
a[++ans] = i;
}
}
cout << ans << '\n';
for (int i = 1; i <= ans; i++) {
cout << a[i] << ' ';
}
return 0;
}
Task D Square Permutation
赛时第一发没判前导零,导致 WA 了好多,第二发过了。
枚举平方数,但是是平方数的平方根。
注意:可能有前导 0。
#include <bits/stdc++.h>
using namespace std;
int n;
long long ans;
string s;
int cnt[10], cnt2[10];
int main() {
cin >> n >> s;
for (int j = 0; j < n; j++) {
cnt2[s[j] - '0']++;
}
for (int i = 0; 1ll * i * i <= 9999999999999ll; i++) {
long long x = 1ll * i * i;
fill(cnt, cnt + 10, 0);
for (; x; x /= 10) {
cnt[x % 10]++;
}
bool flag = 0;
for (int j = 0; j < 10; j++) {
if ((j && cnt[j] != cnt2[j]) || (!j && cnt[j] > cnt2[j])) {
flag = 1;
break;
}
}
ans += !flag;
}
cout << ans;
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)