Advertisement
leminhkt

noname50

Apr 30th, 2020
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<time.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll long long
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.         /* ----------------- ~~~~~~~ ----------------- */
  16.  
  17.     ll l, r, m, res;
  18.  
  19. /* ----------------- ~~~~~~~ ----------------- */
  20.  
  21. int main(){
  22.    
  23.     //freopen("INPUT.inp", "r", stdin);
  24.     //freopen("OUTPUT.out", "w", stdout);
  25.     ios_base::sync_with_stdio(0); cin.tie(0);
  26.  
  27.         /* ----------------- main func ----------------- */
  28.  
  29.     srand(time(0));
  30.     cin >> l >> r >> m;
  31.     res = m;
  32.     while(clock() <= 0.95*CLOCKS_PER_SEC){
  33.         int x = rand()%(r - l + 1) + l;
  34.         if(x != l)
  35.             res = min(res, x*(rand()%(x - l) + l)%m);
  36.         if(x != r)
  37.             res = min(res, x*(rand()%(r - x) + x + 1)%m);
  38.     }
  39.     cout << res;
  40.  
  41. /* ----------------- ~~~~~~~~~ ----------------- */
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement