题目链接:Codeforces 466B Wonder Room
题目大意:给定n,a,b,要求找到ai,bi,(ai≥a, bi≥b)并且ai∗bi≥6∗n,并且ai∗bi要尽量小。
解题思路:枚举ai,根据6n算出需要的bi,注意ai只需要枚举到
6n
‾‾‾√
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
int main () {
bool flag = false;
ll n, a, b, ans = INF, l, r;
scanf("%lld%lld%lld", &n, &a, &b);
n *= 6;
if (a > b) {
swap(a, b);
flag = true;
}
for (ll i = 1; i <= n; i++) {
ll x = i, y = (n - 1) / i + 1;
if (x > y)
break;
x = max(x, a);
y = max(y, b);
if (x * y < ans) {
ans = x * y;
l = x;
r = y;
}
}
if (flag)
swap(l, r);
printf("%lld\n%lld %lld\n", ans, l, r);
return 0;
}
分享到:
相关推荐
Codeforces - 1107B. Digital root & 1107C. Brutality(规律 & 贪心)Codeforces - 1107B.
Codeforces 题库 101-200 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
Codeforces 1105B - Zuhair and Strings 测试点37个(全)
Codeforces 题库 001-100 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
codeforces编程网站预测分数插件
使用于Google Chrome的Codeforces Enhancer 1.1.2插件安装包。 版本:codeforces enhancer 1.1.2 使用浏览器:Google Chrome
Codeforces 185A - Plant 全测试点49个
codeforces 19 E Fairy 一道比较难的题目的解题报告 推荐阅读
Codeforces global round 10 codes
Codeforces round 678 division 2 codes
Some of the Codeforces problems codes
lucifer1004大佬的博客cf上分攻略故里大佬的githubcf思维题刷题数:44- (1421)codeforces 676 div2 A,B done
Codeforces round 678 D2_Codeforces_源码
打codeforces的神器
一个Codeforces、牛客竞赛、AtCoder平台的编程竞赛查询插件,ACMer必备.zip
codeforces-js Codeforces JS
使用 C# + WPF 开发 --- 还在发愁打了那么多场比赛都没有进入首页么? 还在为了前 5 的 hacker 名额阅读千份代码么? 是的,你没有看错! 这是一个 Edu & Div.3 轮 Open hacking 错误代码自动查找器!...
Codeforces Round #723 (Div. 2).md
Codeforces 题库 201-294 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
接受串子-接受字符串相等-接受Codeforces回合#684(Div.2) 2/6 1440A-购买琴弦-接受1440B -中位数的总和-已接受1440C1-二进制表(简易版)-已接受1440C2-二进制表(硬版)-已接受 Codeforces回合#683(分区2) 1/...