2015-05-11 21:10:35

总结:迟到了N天的题解...

  状态比较浮躁... 只搞了一题+hack+2-1... 来说说题目吧。

 

A题 hdu 5224:暴力题

  水题... 只要从 1~sqrt(n) 枚举一下就可以了。

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MP(a,b) make_pair(a,b)
#define PB(a) push_back(a)

typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;

int T,n;

int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        int a = (int)sqrt(1.0 * n);
        int b = 0;
        for(int i = a; i <= n; ++i){
            if(n % i == 0){
                a = i;
                b = n / i;
                break;
            }
        }
        printf("%d\n",a + a + b + b);
    }
    return 0;
}
View Code

相关文章: