hpnq

Time limit

Nov 28th, 2022
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. // sqrt(n)*sqrt(n) https://codeforces.com/group/mE6q0CijMT/contest/412684/problem/A
  2. #include <bits/stdc++.h>
  3. #define loop(x, n) for (int i = x; i < n; i++)
  4. #define err cout << "ERROR" << endl;
  5. #define all(x) x.begin(), x.end()
  6. #define f first
  7. #define s second
  8. #define  pii pair<int, int>
  9. #define pb push_back
  10. typedef long long ll;
  11.  
  12. #define DEBUG 1
  13.  
  14.  
  15. using namespace std;
  16.  
  17.  
  18. #define DEBUG 1
  19.  
  20. ll dvs(ll x){
  21.     ll cnt = 0;
  22.  
  23.     ll d = 0;
  24.  
  25.     for(ll i = 2; i * i < x; i++ ){
  26.         if(x%i == 0){
  27.             cnt++;
  28.         }
  29.         d = i;
  30.     }
  31.     cnt*=2;
  32.     d++;
  33.     if(d*d == x){
  34. //        cout << d << "\n";
  35.         cnt++;
  36.     }
  37.     return cnt + 2;
  38.  
  39. }
  40.  
  41. void solve(){
  42.     ll n;
  43.     cin >> n;
  44.     ll mx = 0, ans = 1;
  45. //    cout << dvs(n);
  46.     for(ll i = n; i*i >= n; i-- ){
  47.         ll xuq = dvs(i);
  48. //        cout << xuq<<"\n";
  49.         mx = max(mx, xuq);
  50.         if(mx == xuq){
  51.             ans = i;
  52.         }
  53.     }
  54.     cout << mx << "  "<< ans;
  55. }
  56.  
  57.  
  58. int main() {
  59. #ifdef DEBUG
  60.     freopen("text.txt", "r", stdin);
  61. #else
  62.     freopen("divisors.in", "r", stdin);
  63.     freopen("divisors.out", "w", stdout);
  64.  
  65.  
  66. #endif
  67.     solve();
  68.     return 0;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment