#include<iostream> #include<cstdio> #define ll long long using namespace std; int main(){ ll a,m,n; scanf("%lld",&a);//b = a+m,c = a+n,mn = a*a+1 for(m=a;m>=1;m--) if((a*a+1)%m==0) { break; } n = (a*a+1)/m; printf("%lld\n",a*2+m+n); return 0; }
2023-11-28 12:00:45
#include<iostream> #include<cstdio> #define ll long long using namespace std; int main(){ ll a,m,n; scanf("%lld",&a);//b = a+m,c = a+n,mn = a*a+1 for(m=a;m>=1;m--) if((a*a+1)%m==0) { break; } n = (a*a+1)/m; printf("%lld\n",a*2+m+n); return 0; }