Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why WA? 纯暴力#include <iostream> #include <sstream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cmath> #include <string.h> using namespace std; #define REP(i, n) for(int i = 0; i<(n); i++) #define abs(a) ((a) >= 0 ? (a) : -(a)) #define inf 999999999 typedef vector<int> VI; typedef vector<string> VS; typedef long long i64; typedef unsigned long long u64; int n; void go() { int res = inf; for (int i = 1; i < n/2+1 ; i++) { if (n % i == 0) { for (int j = 1; j < n/i; j++) { if (n%(i*j) == 0) { int k = n/(i*j); int t = 2*i*j + 2*i*k +2*j*k; if (t < res) res = t; } } } } printf("%d\n", res); } int main() { int C; cin>>C; for (int i = 0; i < C; i++) { cin>>n; if (n == 0) {printf("0\n"); continue;} go(); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator