QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#260455#7692. Prof. Fumblemore and the Collatz ConjectureItsJerr#AC ✓1ms3480kbC++171.9kb2023-11-22 10:22:492023-11-22 10:22:50

Judging History

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

  • [2023-11-22 10:22:50]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3480kb
  • [2023-11-22 10:22:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

void print(__int128 x) {
    if (x > 9) print(x / 10);
    putchar(x % 10 + '0');
}

__int128 read() {
    __int128 x = 0;
    string s; cin >> s;
    reverse(s.begin(), s.end());
    while (s.size()) {
        x = x * 10 + s.back() - '0';
        s.pop_back();
    }
    return x;
}

bool test(__int128 x) {
    while (x % 2 == 0) x /= 2;
    return x == 1;
}

signed main() {
    // cin.tie(0)->sync_with_stdio(0);
    if (fopen("qoj_7692.inp", "r")) {
        freopen("qoj_7692.inp", "r", stdin);
        freopen("qoj_7692.out", "w", stdout);
    }

    #ifdef LOCAL_MACHINE 
        if (fopen("task.inp", "r")) {
            freopen("task.inp", "r", stdin);
            freopen("task.out", "w", stdout);
        }
    #endif

    string s; cin >> s;
    for (int i = 0; i + 1 < s.size(); ++i) if (s[i] == 'O' && s[i + 1] == 'O') {
        cout << "INVALID\n";
        exit(0);
    }
    if (s.back() == 'E') {
        cout << "INVALID\n";
        exit(0);
    }

    int ce = 0;
    for (int i : s) ce += i == 'E';

    unsigned __int128 ans = 0; 
    ans -= 1;

    for (int ed = 2; ed < 128 - ce; ++ed) {
        __int128 x = 1;
        for (int i = 0; i < ed; ++i) x *= 2;

        bool ok = 1;
        for (int i = (int)s.size() - 1; ~i; --i) {
            if (s[i] == 'O') {
                x -= 1;
                if (x % 3 != 0) {
                    ok = 0;
                    break;
                }
                x /= 3;
                if (x % 2 == 0) {
                    ok = 0;
                    break;
                }
            }
            else x *= 2;

            if (test(x)) {
                ok = 0;
                break;
            }
        }

        if (ok && ans > x) ans = x;
    }

    print(ans);
}

// ඞඞඞඞඞ you sus

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3436kb

input:

EEOEO

output:

12

result:

ok single line: '12'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3376kb

input:

EEOOEO

output:

INVALID

result:

ok single line: 'INVALID'

Test #3:

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

input:

OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

383

result:

ok single line: '383'

Test #4:

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

input:

OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

931

result:

ok single line: '931'

Test #5:

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

input:

OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

641

result:

ok single line: '641'

Test #6:

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

input:

OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO

output:

683

result:

ok single line: '683'

Test #7:

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

input:

OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

465

result:

ok single line: '465'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3404kb

input:

OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

481

result:

ok single line: '481'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3384kb

input:

OEEOEOEO

output:

201

result:

ok single line: '201'

Test #10:

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

input:

OEEEEOEEOEOEEEOEOEEOEEEO

output:

133

result:

ok single line: '133'

Test #11:

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

input:

OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO

output:

943

result:

ok single line: '943'

Test #12:

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

input:

OEEEOEEO

output:

301

result:

ok single line: '301'

Test #13:

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

input:

OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

407

result:

ok single line: '407'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3400kb

input:

OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

191

result:

ok single line: '191'

Test #15:

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

input:

OEEEOEO

output:

605

result:

ok single line: '605'

Test #16:

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

input:

OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

431

result:

ok single line: '431'

Test #17:

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

input:

OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO

output:

563

result:

ok single line: '563'

Test #18:

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

input:

OEEOEEEEEOEEOEEEO

output:

241

result:

ok single line: '241'

Test #19:

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

input:

OEEEOEEEEOEOEEEOEOEEOEEEO

output:

269

result:

ok single line: '269'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3416kb

input:

EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

540

result:

ok single line: '540'

Test #21:

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

input:

OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

575

result:

ok single line: '575'

Test #22:

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

input:

EEOEEOEOEEEEEOEOEOEEEEEO

output:

868

result:

ok single line: '868'

Test #23:

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

input:

OEOEOEO

output:

26512143

result:

ok single line: '26512143'

Test #24:

score: 0
Accepted
time: 1ms
memory: 3432kb

input:

OEOEOEEO

output:

13256071

result:

ok single line: '13256071'

Test #25:

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

input:

EEO

output:

20

result:

ok single line: '20'

Test #26:

score: 0
Accepted
time: 1ms
memory: 3468kb

input:

EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE

output:

INVALID

result:

ok single line: 'INVALID'

Test #27:

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

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO

output:

43980465111040

result:

ok single line: '43980465111040'

Test #28:

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

input:

EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO

output:

7321693729792

result:

ok single line: '7321693729792'

Test #29:

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

input:

EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO

output:

1028529777000

result:

ok single line: '1028529777000'