标签:
原题
Description
Input
Output
Sample Input
Sample Output
#include<iostream> #include<cstdio> #include<stack> #include<algorithm> using namespace std; int is_prime(int x) { for (int i = 2; i * i <= x; i++) if (x % i == 0) return 0; return 1; } int main() { int t, n; int sq; cin >> t; while (t--) { int ans,temp; int flag = 0; cin >> n; if (is_prime(n)) ans = 2 + 2 * n; sq = sqrt(n); for (int i = sq; i > 0; i--) { if (n%i == 0) { temp = n / i; ans =2* i +2 * temp; break; } } cout << ans << endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/shawn-ji/p/4696571.html