Codeforces Round #634 (Div. 3) 比赛人数11922 慢慢的对Div. 3难度有了些感觉
[codeforces 1335B] Construct the String b代表周期
总目录详见https://blog.csdn.net/mrcrack/article/details/103564004
在线测评地址https://codeforces.com/contest/1335/problem/B
Problem | Lang | Verdict | Time | Memory |
---|---|---|---|---|
B - Construct the String | GNU C++17 | Accepted | 31 ms | 0 KB |
比赛时,左想右想,无果,在纸上写写画画。突然,神来一笔,b代表不同的字母数,那就创造b个连续不同的字母,进行不断的拼接。
手工算法如下
7 5 3
abcabca
6 1 1
aaaaaa
6 6 1
aaaaaa
5 2 2
ababa
读者应该能看到,a值就是个摆设,在该题无用。
AC代码如下
#include <stdio.h>
char s[2010];
int main(){
int t,n,a,b,i,j;
scanf("%d",&t);
while(t--){
scanf("%d%d%d",&n,&a,&b);
for(i=0;i<n;i++)
s[i]='a'+i%b;
s[n]='\0';
printf("%s\n",s);
}
return 0;
}