AtCoder ABC 306 解析

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

目录

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}A0​20+A1​21+⋯+A63​263.

Co

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值