Submission #8622845


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x;

    if (a * 1000000000 + b * 10 <= x) {
        cout << 1000000000 << "\n";
        return 0;
    }

    ll ans = 0;
    ll hoge = 1000000000;
    for (int i = 9; i >= 1; i--) {
        ll foo = (x - i * b) / a;
        if (foo >= hoge) {
            ans = max(ans, hoge - 1);
        } else if (foo >= hoge / 10) {
            ans = max(ans, foo);
        }
        hoge /= 10;
    }
    cout << ans << "\n";
    return 0;
}

Submission Info

Submission Time
Task C - Buy an Integer
User fine
Language C++14 (GCC 5.4.1)
Score 300
Code Size 629 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 16
Set Name Test Cases
sample sample01, sample02, sample03, sample04
All border01, border02, border03, corner01, max01, max02, max03, min01, min02, rnd01, rnd02, rnd03, sample01, sample02, sample03, sample04
Case Name Status Exec Time Memory
border01 AC 1 ms 256 KB
border02 AC 1 ms 256 KB
border03 AC 1 ms 256 KB
corner01 AC 1 ms 256 KB
max01 AC 1 ms 256 KB
max02 AC 1 ms 256 KB
max03 AC 1 ms 256 KB
min01 AC 1 ms 256 KB
min02 AC 1 ms 256 KB
rnd01 AC 1 ms 256 KB
rnd02 AC 1 ms 256 KB
rnd03 AC 1 ms 256 KB
sample01 AC 1 ms 256 KB
sample02 AC 1 ms 256 KB
sample03 AC 1 ms 256 KB
sample04 AC 1 ms 256 KB