cf466B Wonder Room
1 second
256 megabytes
standard input
standard output
The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has aa × b square meter wonder room. The caretaker wants to accommodate exactly n students there. But the law says that there must be at least 6 square meters per student in a room (that is, the room for n students must have the area of at least 6n square meters). The caretaker can enlarge any (possibly both) side of the room by an arbitrary positive integer of meters. Help him change the room so as all nstudents could live in it and the total area of the room was as small as possible.
The first line contains three space-separated integers n, a and b (1 ≤ n, a, b ≤ 109) — the number of students and the sizes of the room.
Print three integers s, a1 and b1 (a ≤ a1; b ≤ b1) — the final area of the room and its sizes. If there are multiple optimal solutions, print any of them.
3 3 5
18
3 6
2 4 4
16
4 4
第二题题意是有n*m的方格,可以增加n、m的值,但不能减少。要求使得(n')*(m')>=6k,求n' * m' 的最小值,及此时的n' * m'
以为是很厉害的数论……当时比赛中没想出来……后来写个爆搜竟然A了……后悔莫及
就是从6k开始判断可行性,不行就一直+1+1……
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define LL long long
using namespace std;
LL n,m,k;
bool rev;
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int main()
{
k=read();n=read();m=read();
if (n>m)swap(n,m),rev=1;
if (n*m>=6*k)
{
printf("%lld\n%lld %lld",n*m,n,m);
return 0;
}
k*=6;
while (1)
{
bool mrk=0;LL a=0;
for (int i=n;i<=sqrt(k);i++)
if (k%i==0&&k/i>=m)
{
mrk=1;
a=i;
break;
}
if (mrk)
{
if (!rev)printf("%lld\n%lld %lld",k,a,k/a);
else printf("%lld\n%lld %lld",k,k/a,a);
return 0;
}else k++;
}
}
cf466B Wonder Room的更多相关文章
随机推荐
- 安卓手机用-----Exchange Activesync---同步Gmail日历联系人
微软Exchange Activesync是一个跨平台的移动设备同步协议 支持很多手机操作系统,比如诺基亚的塞班.黑莓的palm.WindowsMobile.Iphone.安卓等.这些手机上都可以用这 ...
- Socket也有专门的Unicode版本
https://www.chilkatsoft.com/refdoc/wcppCkSocketWRef.html https://www.chilkatsoft.com/refdoc/vcCkSock ...
- Go代理,修改标题
- UVA 712-S-Trees(满二叉树的简单查询)
题意:给一棵满二叉树,叶子节点赋予权值,0或者1,对于每个查询输出叶子节点的权值,每个查询0代表往左走,1代表往右走,这题坑的地方是层的访问顺序,如第二组测试,由上到下依次是x3,x1,x2,假如给一 ...
- LeeCode-Pow(x, n)
Implement pow(x, n). double myPow(double x, int n) { ) return 1.0; ) return 1.0/pow(x,-n); ); }
- Android ScrollView用法
Android ScrollView用法 今天试着使用了一下Android的滚轮,以下是一个小小的测试,读取测试文件,主要是使用scrollTo函数和getScrollY(),程序点击BUTTON按钮 ...
- C#常用語法糖(Csharp Syntactic sugar)
首先需要声明的是“语法糖”这个词绝非贬义词,它可以给我带来方便,是一种便捷的写法,编译器会帮我们做转换:而且可以提高开发编码的效率,在性能上也不会带来损失.这让java开发人员羡慕不已,呵呵. 1. ...
- WinForm实现窗体最小化后小图标在右边任务栏下
一 基本功能1. 首先新建一个窗体,然后拖入一个名为 NotifyIcon 的控件,名字我没有改,就那个名字 2. 我的应用程序下有些图标文件,这里我用这个图标,我选择 013.ico 3. 选择 ...
- android 补间动画
android开发过程中,为了更好的展示应用程序,应用程序添加动画,能够很好地实现这个功能.如果动画中的图像变化有一定的规律,可以采用自动生成图像的方式来生成动画,例如图像的移动.旋转.缩放等.自动生 ...
- hdu2304Electrical Outlets
Problem Description Roy has just moved into a new apartment. Well, actually the apartment itself is ...