AtCoder ABC306 A~D 题解
[比赛源网站]:https://atcoder.jp/contests/abc306
A
[AtCoder 原题]:https://atcoder.jp/contests/abc306/tasks/abc306_a
题意简述
给定长度为 N 的字符串 S。请你求出 S[1]S[1]S[2]S[2]...S[N]S[N] 构成的字符串。
思路
直接输入然后模拟即可。
时间复杂度:O(n)。
Code
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
cin >> n >> s;
for (int i = 0; i < n; i++){
cout << s[i] << s[i];
}
return 0;
}
B
[AtCoder 原题]:https://atcoder.jp/contests/abc306/tasks/abc306_b
题意简述
给定长度为 64 的 01 序列 A[0] ~ A[63]。求出题目的式子的值。
分析
同样也是直接模拟即可。
但是注意要开 `unsigned long long` 或 `__int128` 或 `__int128_t`。
Code
#include<bits/stdc++.h>
using namespace std;
unsigned long long ans, cnt = 1;
int main(){
for (int i = 1; i <= 64; i++){
long long x;
cin >> x;
ans += x * cnt;
cnt *= 2;
}
cout << ans;
return 0;
}
C
请参阅 [AtCoder ABC306 C Centers 题解:https://www.luogu.com.cn/blog/tianbiandeshenghuo11/solution-at-abc306-c。
# D
请参阅 [AtCoder ABC306 D Poisonous Full-Course 题解]:(https://www.luogu.com.cn/blog/tianbiandeshenghuo11/solution-at-abc306-d)。