QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#76626#5115. Clone RanranperspectiveAC ✓51ms3708kbC++23872b2023-02-11 04:21:592023-02-11 04:22:01

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-11 04:22:01]
  • 评测
  • 测评结果:AC
  • 用时:51ms
  • 内存:3708kb
  • [2023-02-11 04:21:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

long long query(int a, int b, int c, int l)
{
    auto value = [&](int v) {
        return 1LL * v * a + 1LL * (c + v - 1) / v * b;
    };

    int s = 1, e = l;
    while (s < e) {
        int mid = (s + e) / 2;
        if (value(mid) < value(mid + 1)) {
            e = mid;
        } else {
            s = mid + 1;
        }
    }

    return value(s);
}

void solve()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    long long ans = 1LL << 60;
    for (int p = 0; p <= 30; ++p) {
        int temp = 1 << p;
        long long cand = 1LL * a * p + 1LL * (c + temp - 1) / temp * b;
        ans = min(ans, cand);
    }

    printf("%lld\n", ans);
}

int main()
{
    int cases;
    scanf("%d", &cases);

    while (cases--) {
        solve();
    }

    return 0;
}

详细

Test #1:

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

input:

5
1 1 1
2 3 3
9 9 9
3 26 47
1064 822 1048576

output:

1
7
45
44
21860

result:

ok 5 number(s): "1 7 45 44 21860"

Test #2:

score: 0
Accepted
time: 51ms
memory: 3560kb

input:

99500
1000000000 1000000000 1000000000
1000000000 1000000000 999999999
1000000000 1000000000 999999998
1000000000 1000000000 999999997
1000000000 1000000000 999999996
1000000000 1000000000 999999995
1000000000 1000000000 999999994
1000000000 1000000000 999999993
1000000000 1000000000 999999992
10000...

output:

31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
31000000000
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999998
30999999996
30999999996
30999999996
30999999996
30999999996
...

result:

ok 99500 numbers