#include<iostream> #include<stdio.h> using namespace std; int main() { //freopen("acm.acm","r",stdin); unsigned long a; unsigned long m; unsigned long n; unsigned long tem; cin>>a; tem = a*a + 1; for(m = a; m>=1 ; -- m) { if((a*a + 1)%m == 0) break; } n = tem/m; cout<<m+n+2*a<<endl; }
时间: 2024-12-20 00:35:49