栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 3499 Containers

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 3499 Containers

#include <vector>#include <list>#include <map>#include <set>#include <deque>#include <queue>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <cctype>#include <string>#include <cstring>#include <ctime>#include <string.h>using namespace std;const double pi = acos(-1.0);const double eps = 1E-7;typedef long long int64;typedef unsigned long long uint64;#define two(X) (1<<(X))#define twoL(X) (((int64)(1))<<(X))#define contain(S,X) (((S)&two(X))!=0)#define containL(S,X) (((S)&twoL(X))!=0)#define sqr(x) ((x)*(x))#define Abs(x) ((x) < 0 ? (-(x)) : (x))typedef pair<int,int> ipair;#define SIZE(A) ((int)A.size())#define MP(A,B) make_pair(A,B)#define PB(X) push_back(X)#define ME(a) memset((a), 0, sizeof((a)))#define MM(a, b) memcpy((a), (b), sizeof((a)))#define FOR(i,n) for (int (i) = 0; (i) < (n); ++(i))#define REP(i,a,b) for (int (i) = (a); (i) < (b); ++(i))int64 n;int main(){ int Tests; for (scanf("%d", &Tests); Tests--; ) { scanf("%I64d", &n); if (!(n % 5)) n /= 5; else n = n / 5 + 1; int64 ans = n * 1000, ax, ay, tans = ans; for (int64 o = 1; o * o <= n; ++o) { int64 x = o; int64 y = n / x; if (n % x) ++y; int64 tmp = (x * 8 + (x + 1) * 2) * (y * 40 + (y + 1) * 4); int64 ww = Abs((x * 8 + (x + 1) * 2) - (y * 40 + (y + 1) * 4)); if (tmp < ans || tmp == ans && ww < tans) { ans = tmp; tans = ww; ax = y * 40 + (y + 1) * 4; ay = x * 8 + (x + 1) * 2; } swap(x, y); tmp = (x * 8 + (x + 1) * 2) * (y * 40 + (y + 1) * 4); ww = Abs((x * 8 + (x + 1) * 2) - (y * 40 + (y + 1) * 4)); if (tmp < ans || tmp == ans && ww < tans) { ans = tmp; tans = ww; ax = y * 40 + (y + 1) * 4; ay = x * 8 + (x + 1) * 2; } } if (ax < ay) swap(ax, ay); printf("%I64d X %I64d = %I64dn", ax, ay, ans); } return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/381809.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号