QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#612368 | #7692. Prof. Fumblemore and the Collatz Conjecture | EchoDream | AC ✓ | 1ms | 3820kb | C++14 | 1.3kb | 2024-10-05 10:44:20 | 2024-10-05 10:44:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
int main() {
string str;
cin >> str;
for (int i = 0; i < str.size(); i++) {
if (str[i] != 'E' && str[i] != 'O') {
cout << "INVALID" << endl;
return 0;
}
}
if (str[str.size() - 1] != 'O') {
cout << "INVALID" << endl;
return 0;
}
for (int i = 0; i < str.size() - 2; i++) {
if (str[i] == 'O' && str[i + 1] == 'O') {
cout << "INVALID" << endl;
return 0;
}
}
ll num = 16;
int p = 0;
while (1) {
ll number = num;
int check = 0;
bool jud = 1;
for (int i = str.size() - 1; i >= 0; i--) {
if (str[i] == 'E') {
number *= 2;
ll pp = number;
while (pp % 2 == 0 && pp != 0)
pp /= 2;
if (pp == 0)
check = 1;
} else if (str[i] == 'O') {
if ((number - 1) % 3 == 0) {
number = (number - 1) / 3;
if (number == 1)
check = 0;
} else {
jud = 0;
break;
}
}
}
if (check) {
num *= 2;
p++;
continue;
}
if (jud) {
cout << number << endl;
break;
}
num *= 2;
p++;
if (p > 70) {
cout << "INVALID" << endl;
break;
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3512kb
input:
EEOEO
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
EEOOEO
output:
INVALID
result:
ok single line: 'INVALID'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
383
result:
ok single line: '383'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
931
result:
ok single line: '931'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
641
result:
ok single line: '641'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO
output:
683
result:
ok single line: '683'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
465
result:
ok single line: '465'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
481
result:
ok single line: '481'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
OEEOEOEO
output:
201
result:
ok single line: '201'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
OEEEEOEEOEOEEEOEOEEOEEEO
output:
133
result:
ok single line: '133'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO
output:
943
result:
ok single line: '943'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
OEEEOEEO
output:
301
result:
ok single line: '301'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
407
result:
ok single line: '407'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
191
result:
ok single line: '191'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
OEEEOEO
output:
605
result:
ok single line: '605'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
431
result:
ok single line: '431'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO
output:
563
result:
ok single line: '563'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
OEEOEEEEEOEEOEEEO
output:
241
result:
ok single line: '241'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
OEEEOEEEEOEOEEEOEOEEOEEEO
output:
269
result:
ok single line: '269'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
540
result:
ok single line: '540'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
575
result:
ok single line: '575'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
EEOEEOEOEEEEEOEOEOEEEEEO
output:
868
result:
ok single line: '868'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
OEOEOEO
output:
26512143
result:
ok single line: '26512143'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
OEOEOEEO
output:
13256071
result:
ok single line: '13256071'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
EEO
output:
20
result:
ok single line: '20'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE
output:
INVALID
result:
ok single line: 'INVALID'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO
output:
43980465111040
result:
ok single line: '43980465111040'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO
output:
7321693729792
result:
ok single line: '7321693729792'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO
output:
1028529777000
result:
ok single line: '1028529777000'