/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 512.0 KiB
#2 Accepted 3ms 332.0 KiB
#3 Accepted 4ms 552.0 KiB
#4 Accepted 4ms 332.0 KiB
#5 Accepted 5ms 552.0 KiB
#6 Accepted 34ms 660.0 KiB
#7 Accepted 274ms 1.875 MiB
#8 Accepted 313ms 1.629 MiB
#9 Accepted 294ms 1.855 MiB
#10 Accepted 254ms 2.277 MiB
#11 Accepted 284ms 2.176 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
  ll tc;
    cin>>tc;
    while(tc--)
    {
        ll n,m;
        cin>>n>>m;
       ll l=0,r=m/n,ans=0;
        while(l<=r)
        {
            ll mid=(l+(r-l)/2);
            ll u=mid*n;
            ll d=(m-(u));
            ll g=d*mid;
            if(d>=u)
            {
                ans=max(ans,g);
                l=mid+1;
            }
            else
            {
                ans=max(ans,g);
                r=mid-1;
            }
        }
        cout<<ans<<endl;
    }
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-06 14:05:15
Judged At
2024-11-11 02:55:57
Judged By
Score
100
Total Time
313ms
Peak Memory
2.277 MiB