QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#69853#5115. Clone Ranranmagicduck#WA 2ms3272kbC++141.3kb2023-01-02 13:43:062023-01-02 13:43:10

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-02 13:43:10]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3272kb
  • [2023-01-02 13:43:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <typename T> inline void read(T &F) {
    int R = 1; F = 0; char CH = getchar();
    for(; !isdigit(CH); CH = getchar()) if(CH == '-') R = -1;
    for(; isdigit(CH); CH = getchar()) F = F * 10 + CH - 48;
    F *= R;
}
inline void file(string str) {
    freopen((str + ".in").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
}
const int Log = 40;
LL a, b, c, pw[Log];

LL calc(LL x) {
    LL ans = 0;
    for(int i = 1; i <= 100; i++) {
        if(i * b > x) break;
        LL lg = (x - i * b) / a;
        if(lg >= 31) return 1e18;
        ans = max(ans, pw[lg] * i);
    }
    return ans;
}

int main() {
    //file("");
    pw[0] = 1;
    for(int i = 1; i < Log; i++)
        pw[i] = pw[i - 1] * 2;
    int T; read(T);
    while(T--) {
        read(b), read(a), read(c);
        LL l = 0, r = c * b, res = 0;
        while(l <= r) {
            LL mid = (l + r) >> 1;
            if(calc(mid) >= c) res = mid, r = mid - 1;
            else l = mid + 1;
        }
        cout << res << '\n';
    }   
    
    #ifdef _MagicDuck
        fprintf(stderr, "# Time: %.3lf s", (double)clock() / CLOCKS_PER_SEC);
    #endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3272kb

input:

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

output:

1
6
45
88
17504

result:

wrong answer 2nd numbers differ - expected: '7', found: '6'