📄 e.cpp
字号:
// Problem E
// http://acm.uva.es/p/v108/10896.html
// Solution by semiconductor
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
char buf[100], word[100];
char str[100];
void
Solve(void)
{
char ans[26];
int nans = 0;
for ( int i = 0; i < 26; i++ ) {
strcpy(str, buf);
for ( int j = 0; str[j]; j++ )
if ( islower(str[j]) ) str[j] = (str[j] - 'a' + i) % 26 + 'a';
char *tok, *s = str;
while ( tok = strtok(s, " \n") ) {
s = 0;
if ( strcmp(tok, word) == 0 ) ans[nans++] = (26 - i) % 26 + 'a';
}
}
sort(ans, ans + nans);
printf("%.*s\n", nans, ans);
}
int
main()
{
int T;
scanf("%d", &T);
fgets(buf, sizeof buf, stdin);
while ( T-- ) {
fgets(buf, sizeof buf, stdin);
scanf("%s", word);
Solve();
fgets(buf, sizeof buf, stdin);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -