/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 344.0 KiB
#2 Accepted 2ms 540.0 KiB
#3 Accepted 355ms 564.0 KiB
#4 Accepted 261ms 564.0 KiB
#5 Time Exceeded ≥1012ms ≥568.0 KiB
#6 Time Exceeded ≥1083ms ≥584.0 KiB
#7 Time Exceeded ≥1059ms ≥596.0 KiB
#8 Accepted 529ms 1.672 MiB
#9 Time Exceeded ≥1040ms ≥836.0 KiB
#10 Time Exceeded ≥1024ms ≥512.0 KiB
#11 Time Exceeded ≥1032ms ≥540.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-10-03 13:02:49
Judged By
Score
40
Total Time
≥1083ms
Peak Memory
≥1.672 MiB