/ SeriousOJ /

Record Detail

Memory Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 8ms 772.0 KiB
#3 Time Exceeded ≥1100ms ≥49.633 MiB
#4 Time Exceeded ≥1103ms ≥78.195 MiB
#5 Time Exceeded ≥1097ms ≥32.691 MiB
#6 Time Exceeded ≥1101ms ≥78.301 MiB
#7 Time Exceeded ≥1102ms ≥78.359 MiB
#8 Time Exceeded ≥1106ms ≥174.32 MiB
#9 Time Exceeded ≥1100ms ≥101.812 MiB
#10 Memory Exceeded ≥515ms ≥256.016 MiB
#11 Memory Exceeded ≥517ms ≥256.016 MiB

Code

#include <bits/stdc++.h>
#define int long long
#define endll '\n';
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

const int mod = 1e9 + 7, N = 1e6;
unordered_map<int, int> vis;

void solve()
{

   vis.clear();
   int n, k;
   cin >> n >> k;
   int ans = 0;
   if (n <= k)
   {
      ans = k - n;
   }
   for (int i = 2; i <= 1e9; i++)
   {
      if (i * n > k)
         break;

      if (vis[i] == 0)
      {

         for (int j = i; j <= 1e9; j += i)
         {
            vis[j] = 1;
            int x = j * n;
            if (x <= k)
            {
               ans = max(ans, (j * (k - x)));
            }
            else
            {
               break;
            }
         }
      }
   }

   cout << ans << endll;
}

int32_t main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);
   int t = 1;
   cin >> t;
   while (t--)
   {
      solve();
   }
   return 0;
}

Information

Submit By
Type
Submission
Problem
P1092 Bitwise AND
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-08 15:13:01
Judged At
2024-09-08 15:13:01
Judged By
Score
10
Total Time
≥1106ms
Peak Memory
≥256.016 MiB