QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#260442#7695. Double UpItsJerr#AC ✓1ms3484kbC++171.6kb2023-11-22 10:00:202023-11-22 10:00:20

Judging History

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

  • [2023-11-22 10:00:20]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3484kb
  • [2023-11-22 10:00:20]
  • 提交

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;
}

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

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

    int n; cin >> n; 
    vector<int> a;
    for (int i = 1; i <= n; ++i) {
        __int128 x = read();
        int cur = 0;
        while (x > 1) {
            ++cur;
            x /= 2;
        }
        a.push_back(cur);
    }

    while (a.size() > 1) {
        int mi = 1e9;
        for (int i : a) mi = min(mi, i);

        bool mod = 0;

        for (int i = 0; i + 1 < a.size(); ++i) if (a[i] == a[i + 1] && a[i] == mi) {
            a.erase(a.begin() + i); a.erase(a.begin() + i); a.insert(a.begin() + i, mi + 1); 
            mod = 1;
            break;
        }

        if (mod) continue;

        for (int i = 0; i < a.size(); ++i) if (a[i] == mi) {
            a.erase(a.begin() + i);
            break;
        }
    }

    __int128 res = 1;
    int val = a.back();
    while (val--) res *= 2;

    print(res);
}

// ඞඞඞඞඞ you sus

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
4 2 2 1 8

output:

16

result:

ok single line: '16'

Test #2:

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

input:

1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

512

result:

ok single line: '512'

Test #3:

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

input:

1000
1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650600228229401496703205376 1267650...

output:

649037107316853453566312041152512

result:

ok single line: '649037107316853453566312041152512'

Test #4:

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

input:

1
1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

1
2

output:

2

result:

ok single line: '2'

Test #6:

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

input:

1
4294967296

output:

4294967296

result:

ok single line: '4294967296'

Test #7:

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

input:

1
18446744073709551616

output:

18446744073709551616

result:

ok single line: '18446744073709551616'

Test #8:

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

input:

1
1267650600228229401496703205376

output:

1267650600228229401496703205376

result:

ok single line: '1267650600228229401496703205376'

Test #9:

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

input:

384
18014398509481984 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 72057594037927936 10737418...

output:

618970019642690137449562112

result:

ok single line: '618970019642690137449562112'

Test #10:

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

input:

430
36893488147419103232 128 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248 2251799813685248...

output:

158456325028528675187087900672

result:

ok single line: '158456325028528675187087900672'

Test #11:

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

input:

527
1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 1099511627776 10...

output:

158456325028528675187087900672

result:

ok single line: '158456325028528675187087900672'

Test #12:

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

input:

809
1073741824 77371252455336267181195264 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 2097152 20...

output:

19807040628566084398385987584

result:

ok single line: '19807040628566084398385987584'

Test #13:

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

input:

435
618970019642690137449562112 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 65536 128 128 128 128 128 128 128 128 128 128 128 128 128 ...

output:

316912650057057350374175801344

result:

ok single line: '316912650057057350374175801344'

Test #14:

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

input:

857
4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 4398046511104 43...

output:

1267650600228229401496703205376

result:

ok single line: '1267650600228229401496703205376'

Test #15:

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

input:

765
17592186044416 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 2417851639229258349412352 241785163922925834941...

output:

1237940039285380274899124224

result:

ok single line: '1237940039285380274899124224'

Test #16:

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

input:

122
2097152 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 18014398509481984 ...

output:

10141204801825835211973625643008

result:

ok single line: '10141204801825835211973625643008'

Test #17:

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

input:

491
8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 8192 562949953421312 9444732965739290427392 9444732965739290427392 9444732965739290427392 9444732965739290427392 9444732965739290427392 94447329657392904273...

output:

1267650600228229401496703205376

result:

ok single line: '1267650600228229401496703205376'

Test #18:

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

input:

164
549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 549755813888 5497558138...

output:

20282409603651670423947251286016

result:

ok single line: '20282409603651670423947251286016'