#include <bits/stdc++.h>
using namespace std;
int main() {
//freopen("input.txt","r",stdin);
char s[101];
int a[11];
string ss;
string v[] = {"2", "22", "222", "3", "33", "333", "4", "44", "444", "5", "55", "555", "6", "66", "666", "7", "77", "777", "7777", "8", "88", "888", "9", "99", "999", "9999"};
for (int i = 0; i < 9; ++i) {
int x;
scanf("%d",&x);
a[x] = i + 1;
}
scanf("%s", s); int len = strlen(s);
int last = -1;
for (int i = 0; i < len; ++i) {
if (last == v[s[i] - 'a'][0] - '0') ss += "#";
last = v[s[i] - 'a'][0] - '0'; ss += v[s[i] - 'a'];
}
for (int i = 0; i < (int) ss.size(); ++i) {
if (ss[i] == '#') printf("#"); else printf("%c", '0' + a[ss[i] - '0']);
}
return 0;
}
Compilation message
mobitel.cpp: In function 'int main()':
mobitel.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | scanf("%d",&x);
| ~~~~~^~~~~~~~~
mobitel.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%s", s); int len = strlen(s);
| ~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
224 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |