/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 316.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 251ms 568.0 KiB
#4 Accepted 178ms 564.0 KiB
#5 Accepted 733ms 584.0 KiB
#6 Time Exceeded ≥1095ms ≥600.0 KiB
#7 Time Exceeded ≥1091ms ≥612.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
     ll N, K;
    cin >> N >> K;
    
    if(K <= N ){
        cout << 0 << '\n';
        return;
    }
    ll max_product = (N - K) * N;
    ll res = N, sub = 0 ;
    while(true){
         sub += 1;
         K -= res;
         //cout << N << " " << K << '\n';
        max_product = max(max_product, sub * K);
        //cout << max_product << '\n';
        if(N == K or K < 0) break;
    }

    cout << max_product << '\n';
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
// (k/n) - x == 
// 1 6

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Contest
Brain Booster #5
Language
C++17 (G++ 13.2.0)
Submit At
2024-09-05 17:44:40
Judged At
2024-11-11 02:57:40
Judged By
Score
40
Total Time
≥1095ms
Peak Memory
≥612.0 KiB