目录
A - Echo
B - Base 2
C - Centers
D - Poisonous Full-Course
A - Echo
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 100100 points
Problem Statement
You are given a string SS of length NN consisting of lowercase English letters.
We denote the ii-th character of SS by S_iSi.
Print the string of length 2N2N obtained by concatenating S_1,S_1,S_2,S_2,\dots,S_NS1,S1,S2,S2,…,SN, and S_NSN in this order.
For example, if SS is beginner, print bbeeggiinnnneerr.
Constraints
- NN is an integer such that 1 \le N \le 501≤N≤50.
- SS is a string of length NN consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
NN SS
Output
Print the answer.
Sample Input 1
8 beginner
Sample Output 1
bbeeggiinnnneerr
It is the same as the example described in the problem statement.
Sample Input 2
Copy
3 aaa
Sample Output 2
Copy
aaaaaa
可以定义一个变量来存储要打印的字符串,但在竞争性编程中,所需的只是正确的输出,因此您可以放松并实现以下内容:
用for语句迭代S的每个字符,并打印两次。
在这里,您必须小心,不要打印不必要的空格或换行符。
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
string s;
cin >> n >> s;
for(int i=0;i<n;i++){
cout << s[i] << s[i];
}cout << "\n";
return 0;
}
B - Base 2
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 200200 points
Problem Statement
You are given a sequence A=(A_0,A_1,\dots,A_{63})A=(A0,A1,…,A63) of length 6464 consisting of 00 and 11.
Find A_0 2^0 + A_1 2^1 + \dots + A_{63} 2^{63}A020+A121+⋯+A63263.

文章提供了四个不同的编程问题,涉及字符串重复、二进制序列计算、数组排序以及基于状态的动态规划解题策略。每个问题都包含输入输出示例和解决方案的思路,适合提升编程和算法能力。
最低0.47元/天 解锁文章
522

被折叠的 条评论
为什么被折叠?



