QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#237296#7692. Prof. Fumblemore and the Collatz Conjecturewillow#AC ✓0ms3944kbC++141.1kb2023-11-04 13:43:562023-11-04 13:43:57

Judging History

你现在查看的是最新测评结果

  • [2023-11-04 13:43:57]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3944kb
  • [2023-11-04 13:43:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef __int128 LLL;
const int MAXN = 1000006;

char s[100];
int n;

inline bool Check(LLL x) {
    while (!(x & 1)) {
        x >>= 1;
    }
    return (x == 1);
}

void solve() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    for (int i = 2; i <= 75; ++i) {
        LLL cur = ((LLL)1 << i);
        bool flag = 1;
        for (int j = n; j >= 1; --j) {
            if (s[j] == 'E') {
                cur = cur * 2;
            } else {
                if ((cur - 1) % 3) {
                    flag = 0;
                    break;
                }
                cur = (cur - 1) / 3;
                if (!(cur & 1)) {
                    flag = 0;
                    break;
                }
            }
            if (Check(cur)) {
                flag = 0;
                break;
            }
        }
        if (flag && cur <= (1LL << 47)) {
            printf("%lld\n", (LL)cur);
            return;
        }
    }
    puts("INVALID");
}

int main() {
    solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3880kb

input:

EEOEO

output:

12

result:

ok single line: '12'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

EEOOEO

output:

INVALID

result:

ok single line: 'INVALID'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

383

result:

ok single line: '383'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

931

result:

ok single line: '931'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

641

result:

ok single line: '641'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO

output:

683

result:

ok single line: '683'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

465

result:

ok single line: '465'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

481

result:

ok single line: '481'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

OEEOEOEO

output:

201

result:

ok single line: '201'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

OEEEEOEEOEOEEEOEOEEOEEEO

output:

133

result:

ok single line: '133'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO

output:

943

result:

ok single line: '943'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

OEEEOEEO

output:

301

result:

ok single line: '301'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

407

result:

ok single line: '407'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

191

result:

ok single line: '191'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

OEEEOEO

output:

605

result:

ok single line: '605'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

431

result:

ok single line: '431'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO

output:

563

result:

ok single line: '563'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

OEEOEEEEEOEEOEEEO

output:

241

result:

ok single line: '241'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

OEEEOEEEEOEOEEEOEOEEOEEEO

output:

269

result:

ok single line: '269'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

540

result:

ok single line: '540'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

575

result:

ok single line: '575'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

EEOEEOEOEEEEEOEOEOEEEEEO

output:

868

result:

ok single line: '868'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

OEOEOEO

output:

26512143

result:

ok single line: '26512143'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

OEOEOEEO

output:

13256071

result:

ok single line: '13256071'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

EEO

output:

20

result:

ok single line: '20'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE

output:

INVALID

result:

ok single line: 'INVALID'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO

output:

43980465111040

result:

ok single line: '43980465111040'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO

output:

7321693729792

result:

ok single line: '7321693729792'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO

output:

1028529777000

result:

ok single line: '1028529777000'