[codeforces 1284A] New Year and Naming 字符串+模运算
总目录详见https://blog.csdn.net/mrcrack/article/details/103564004
在线测评地址http://codeforces.com/contest/1284/problem/A
| Problem | Lang | Verdict | Time | Memory |
|---|---|---|---|---|
| A - New Year and Naming | GNU C++11 | Happy New Year! | 31 ms | 0 KB |
#include <stdio.h>
#include <string.h>
char s[25][15],t[25][15];
int n,m;
int main(){
int q,i,y;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)scanf("%s",s[i]);
for(i=0;i<m;i++)scanf("%s",t[i]);
scanf("%d",&q);
while(q--){
char out[30];
scanf("%d",&y),y--;
strcpy(out,s[y%n]);
strcat(out,t[y%m]);
printf("%s\n",out);
}
return 0;
}
本文详细解析了Codeforces平台上的1284A题“新年与命名”,通过字符串操作与模运算实现解决方案,附带完整代码示例。
815

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



