fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define FAST() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  4. #define ui unsigned int
  5. #define ll long long
  6. #define ull unsigned long long
  7. #define fs(n) fixed<<setprecision(n)
  8. #define ers(n) (n).erase(remove((n).begin(), (n).end(), ' ' ), (n).end() ) ;
  9. #define pb(n) push_back(n)
  10. #define pf(n) push_front(n)
  11. #define ppb(n) pop_back(n)
  12. #define ppf(n) pop_front(n)
  13. #define tu(n) toupper(n)
  14. #define tl(n) tolower(n)
  15. #define st(arr,n) sort(arr,arr+n)
  16. #define yes cout<<"yes\n";
  17. #define no cout<<"no\n";
  18. #define Yes cout<<"Yes\n";
  19. #define No cout<<"No\n";
  20. #define YES cout<<"YES\n";
  21. #define NO cout<<"NO\n";
  22. #define sz(x) x.size()
  23. #define charToInt(c) (c-'0')
  24.  
  25. /**************************************************************************************************/
  26.  
  27. void print(vector<int> &v){
  28. int a=v[0];
  29. auto b=v[0];
  30. for(auto x:v){
  31. cout<<x<<" ";
  32. }
  33. cout<<'\n';
  34. }
  35.  
  36. bool temp(int a,int b){
  37. if (a<=b)return true;
  38. else
  39. return false;
  40. }
  41.  
  42. /**************************************************************************************************/
  43. int main() {
  44. FAST();
  45. int x;cin>>x;ll sum=0;int n,n1,n2,min=INT_MAX;
  46. for (int i = 1; i <= sqrt(x); ++i) {
  47. n=x/i;
  48. sum=n+i;
  49. if(n*i==x) {
  50. if (min>sum){
  51. min=sum;
  52. n2=i;n1=n;
  53. }
  54. }
  55. }
  56. cout<<2*(n2+n1);
  57. }
  58.  
  59. /*
  60.   * vector<int>v2(v) >>>>copy elementes from v into v2
  61.   * stoi >>>> convert string to int
  62.  */
Success #stdin #stdout 0.01s 5464KB
stdin
Standard input is empty
stdout
10608