ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#191003 | #3390. 凯撒密码 | diamond_plus | 100 | 25ms | 1272kb | C++ | 2.5kb | 2023-10-07 19:45:34 | 2023-10-07 21:44:51 |
answer
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
using namespace std;
#define rd read()
#define int long long
const int MOD = 998244353;
const int INF = 0x7fffffff;
const int Fill = 0x3f;
const int FillINF = 0x3f3f3f3f;
void write(int n)
{
if (n < 0)
{
putchar('-');
n = -n;
}
if (n < 10)
{
putchar(n + '0');
return;
}
write(n / 10);
putchar(n % 10 + '0');
return;
}
void wt(int n, bool o = 1)
{
write(n);
if (!o)
{
putchar(' ');
}
else
{
putchar('\n');
}
}
int read()
{
char ch;
int type = 1, n = 0;
ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
{
type = -1;
}
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
n = (n << 1) + (n << 3) + (ch ^ 48);
ch = getchar();
}
return n * type;
}
int n;
string s, t;
void solve()
{
int i, j;
int p = 0;
cin >> s >> t;
if (s.size() != t.size())
{
cout << "IMPOSSIBLE";
return ;
}
if (s == t)
{
cout << 0;
return ;
}
int k = 1;
while (k++ < 130)
{
for (i = 0; i < s.size(); i++)
{
if (isdigit(s[i]))
{
s[i] = (s[i] - '0' + 1) % 10 + '0';
}
else
{
s[i] = (s[i] - 'a' + 1) % 26 + 'a';
}
}
if (s == t)
{
cout << k - 1;
return ;
}
// for (i = 0; i < s.size(); i++)
// {
// if (i == 0)
// {
// p = s[i] - t[i];
// }
// bool _1 = isdigit(s[i]), _2 = isdigit(t[i]);
// if (_1 == _2)
// {
// if (s[i] - t[i] != p)
// {
// cout << "IMPOSSIBLE";
// return;
// }
// }
// else
// {
// cout << "IMPOSSIBLE";
// return;
// }
// }
}
cout << "IMPOSSIBLE";
}
signed main()
{
int T;
int i, j;
T = 1;
while (T--)
{
solve();
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
a 0
output:
IMPOSSIBLE
result:
ok single line: 'IMPOSSIBLE'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1224kb
input:
c x
output:
21
result:
ok single line: '21'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1220kb
input:
8 3
output:
5
result:
ok single line: '5'
Test #4:
score: 10
Accepted
time: 1ms
memory: 1232kb
input:
097 097
output:
0
result:
ok single line: '0'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1232kb
input:
135409 357621
output:
2
result:
ok single line: '2'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1272kb
input:
ulhpnmrkblwafxapsldccdplmqukqlxwixjtleoirjyyivdguyiffnvunoxconwjvovmqluhyypgfkmdvgpzjuepkwjdoniezcli...
output:
21
result:
ok single line: '21'
Test #7:
score: 10
Accepted
time: 0ms
memory: 1272kb
input:
ijvxljtolmgjndlwoyjjttakhzvzmihjdhkyfnafwrpeuiuiurusvsnugviqzouvuxalhxmxhclxdzrxylbzsmdruqpnvagkninp...
output:
13
result:
ok single line: '13'
Test #8:
score: 10
Accepted
time: 3ms
memory: 1268kb
input:
lb3zc66k080upg8dfv18jctk0sejke93251mw9f3642u1x7889s5y38wdv39391v3gptt6656248xw576z2w27gh9t3wh5j634lg...
output:
22
result:
ok single line: '22'
Test #9:
score: 10
Accepted
time: 8ms
memory: 1268kb
input:
h18855603165ay78uft01r1i89sx9o1z6d1h0nd2l8f28xe05571r64vjeofr32453571pa1z9x47dpg5k3uw2027lx4270g4xyh...
output:
98
result:
ok single line: '98'
Test #10:
score: 10
Accepted
time: 13ms
memory: 1268kb
input:
2c3hoz6dbcggcjjf665nqfcy3w2yoej1lyr1j523230e2q228b6vn96gsuq1sustb1269uiyrk6y3gi883f789rro7nomg9776w1...
output:
129
result:
ok single line: '129'
Extra Test:
score: 0
Extra Test Passed