QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56660#3889. Balanced Breakdownt3alaMsMs#RE 3ms3736kbC++232.1kb2022-10-20 23:21:592022-10-20 23:22:02

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-20 23:22:02]
  • Judged
  • Verdict: RE
  • Time: 3ms
  • Memory: 3736kb
  • [2022-10-20 23:21:59]
  • Submitted

answer

/// :3
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;

#include "bits/stdc++.h"

#define pb push_back
#define F first
#define S second
#define f(i, a, b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x,y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;

const int N = 3e5+5, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);
const long double EPS = 1e-7;
const int dx[] = {1,1,0,-1,-1,-1,0,1};
const int dy[] = {0,1,1,1,0,-1,-1,-1};
string rev(string s){reverse(all(s)); return s;}
ll getBiggestEven(ll x) {
    ll lo = 0, hi = 1000000000;
    while(lo < hi) {
        ll md = lo + (hi-lo+1)/2;
        if(stoll(to_string(md)+rev(to_string(md))) <= x)
            lo = md;
        else
            hi = md - 1;
    }
    return stoll(to_string(lo)+rev(to_string(lo)));
}
ll getBiggestOdd(ll x) {
    ll ans = min(x, 9ll);
    for(int i = 0; i < 10; i++) {
        ll lo = 1, hi = 1000000000;
        while(lo < hi) {
            ll md = lo + (hi-lo+1)/2;
            if(stoll(to_string(md)+to_string(i)+rev(to_string(md))) <= x)
                lo = md;
            else
                hi = md - 1;
        }
        ll val = stoll(to_string(lo)+to_string(i)+rev(to_string(lo)));
        if(val <= x)ans = max(ans, val);
    }
    return ans;
}
void doWork() {

    ll n;
    cin >> n;
    vector<int> ans;
    while(n) {
        ll x = getBiggestOdd(n);
        ll y = getBiggestEven(n);
        ans.push_back(max(x, y));
        n -= max(x, y);
    }

    assert(ans.size() <= 10);
    cout << ans.size() << '\n';
    for(auto x : ans)
        cout << x << '\n';

}
int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE
    int t = 1;
//    cin >> t;
    while (t--) {
        doWork();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3572kb

input:

1100000

output:

2
1099901
99

result:

ok 

Test #2:

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

input:

1000

output:

2
999
1

result:

ok 

Test #3:

score: 0
Accepted
time: 3ms
memory: 3568kb

input:

10

output:

2
9
1

result:

ok 

Test #4:

score: 0
Accepted
time: 2ms
memory: 3720kb

input:

11005

output:

3
10901
101
3

result:

ok 

Test #5:

score: 0
Accepted
time: 2ms
memory: 3628kb

input:

100000000000000000

output:

2
99999999999999999
1

result:

ok 

Test #6:

score: 0
Accepted
time: 2ms
memory: 3664kb

input:

21

output:

3
11
9
1

result:

ok 

Test #7:

score: 0
Accepted
time: 2ms
memory: 3552kb

input:

1234567887664321

output:

3
1234567887654321
9999
1

result:

ok 

Test #8:

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

input:

690231482249788720

output:

7
690231481184132096
1065555601
100001
1001
11
9
1

result:

ok 

Test #9:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

319173294485481281

output:

7
319173293392371913
1093003901
104401
1001
55
9
1

result:

ok 

Test #10:

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

input:

761353558778227546

output:

7
761353557755353167
1022772201
101101
1001
66
9
1

result:

ok 

Test #11:

score: 0
Accepted
time: 2ms
memory: 3644kb

input:

947179993313410328

output:

7
947179992299971749
1013333101
104401
1001
66
9
1

result:

ok 

Test #12:

score: 0
Accepted
time: 3ms
memory: 3660kb

input:

171408535476134406

output:

7
171408534435804171
1040220401
108801
1001
22
9
1

result:

ok 

Test #13:

score: 0
Accepted
time: 2ms
memory: 3572kb

input:

896452012199589977

output:

7
896452011110254698
1089229801
104401
1001
66
9
1

result:

ok 

Test #14:

score: 0
Accepted
time: 2ms
memory: 3736kb

input:

970894988875162603

output:

7
970894987789498079
1085555801
107701
1001
11
9
1

result:

ok 

Test #15:

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

input:

200429647731477537

output:

7
200429646646924002
1084444801
107701
1001
22
9
1

result:

ok 

Test #16:

score: 0
Accepted
time: 3ms
memory: 3664kb

input:

960284896260606337

output:

5
960284895598482069
662121266
2992
9
1

result:

ok 

Test #17:

score: -100
Dangerous Syscalls

input:

999999999999999999

output:


result: