【链接】 我是链接,点我呀:)

【题意】

让你把长为a,宽为b的房间扩大(长和宽都能扩大)。
使得它的面积达到6*n
问你最小的能满足要求的面积是多少
输出对应的a和b

【题解】

假设aceil(sqrt(6*n))的话
得到的newb = ceil(sqrt(6*n))/newa
newb肯定是小于等于ceil(sqrt(6*n))的
而我们之前newa已经枚举过这种情况了,所以不可能得到更优解。
newb判断一下是不是大于等于b就好
(注意我们在枚举newa的时候,得到的newb ,也会满足newa

【代码】

import java.io.*;
import java.util.*; public class Main { static InputReader in;
static PrintWriter out; public static void main(String[] args) throws IOException{
//InputStream ins = new FileInputStream("E:\\rush.txt");
InputStream ins = System.in;
in = new InputReader(ins);
out = new PrintWriter(System.out);
//code start from here
new Task().solve(in, out);
out.close();
} static int N = 50000;
static class Task{ long n,a,b;
public void solve(InputReader in,PrintWriter out) {
n = in.nextLong();a = in.nextLong();b = in.nextLong();
if (a*b>=6*n) {
out.println(a*b);
out.println(a+" "+b);
return;
}
long temp = (long)Math.sqrt(6*n);
if (temp*temp<6*n) temp++;
long ans = (long)(1e18)+100;
long temp1 = 0,temp2 =0;
boolean f = false;
if (a>b) {
long temp3 = a;a = b;b = temp3;
f =true;
} for (long newa = a;newa <=temp;newa++) {
long newb = (6*n)/newa;
if (newa*newb<(6*n)) newb++; if (newb < b) continue;
if (newa*newb>=6*n && newa*newb<ans) {
ans = Math.min(ans, newa*newb);
temp1 = newa;temp2 = newb;
}
}
if (f) {
long temp3 = temp1;temp1 = temp2;temp2 = temp3;
}
out.println(ans);
out.println(temp1+" "+temp2);
}
} static class InputReader{
public BufferedReader br;
public StringTokenizer tokenizer; public InputReader(InputStream ins) {
br = new BufferedReader(new InputStreamReader(ins));
tokenizer = null;
} public String next(){
while (tokenizer==null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
}catch(IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
} public int nextInt() {
return Integer.parseInt(next());
} public long nextLong() {
return Long.parseLong(next());
}
}
}

【Codeforces 466B】Wonder Room的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  3. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  4. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  5. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  6. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  7. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  8. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

  9. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

随机推荐

  1. 人脸识别(初学篇)-VS2015+opencv3.2的配置

    初学人脸识别,感觉安装也是一个很大的麻烦. 写在这里记录一下吧 一:先安装好我们需要的软件 首先安装Vs2015,在官网或者csdn搜一下应该找的到. 安装步骤没有太多讲究. 点击exe文件,我选择的 ...

  2. python之类的继承及方法讲解分析

    #!/usr/bin/env python#-*- conding:utf-8 -*- # class Person(object):# def __init__(self,name,age):# s ...

  3. python/shell脚本报异常^M: bad interpreter: No such file or directory

    问题:在Windows写了一python脚本,上传Linux服务器执行,报异常*****^M: bad interpreter: No such file or directory 原因:window ...

  4. Pycharm初始创建项目和环境搭建(解决aconda库文件引入不全等问题)

    1.新建工程 1.选择新建一个Pure Python项目,新建项目路径可以在Location处选择. 2.Project Interpreter部分是选择新建项目所依赖的python库,第一个选项会在 ...

  5. Can't install '*' from pristine store, because no checksum is recorded for this file (SVN报错)

    问题:同步.cleanup都会出现下面的提示 svn: E155017: Can't install '*' from pristine store, because no checksum is r ...

  6. Beyond Compare 激活解决办法

    问题: 当你使用过一段时间后会提示有问题,需要激活或者什么. 解决办法: 找到这个路径并删除其下Beyond Compare 3文件夹即可正常使用. C:\Users\******\AppData\R ...

  7. Apache Kafka官方文档翻译(原创)

    Apache Kafka是一个分布式流平台.准确的说是什么意思呢?我们认为流平台具有三种关键能力: 1.让你对数据流进行发布订阅.因此他很像一个消息队列和企业级消息系统. 2.让你以高容错的方式存储数 ...

  8. [转]c++中的string常用函数用法总结

    标准c++中string类函数介绍 注意不是CString之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够.字符串长度等等,而且作为 ...

  9. FJOI2019退役记

    day1 不意外地一点都不紧张,早就感觉没有机会了吧 进场非常从容地读完了三道题,开始写t1暴力,接着就开始自闭,不知道该开t2还是t3,最后先开了t3,想了想这不是选两条不相交的链吗,这个暴力不是林 ...

  10. 关于css宽高问题

    问题:span标签的width和height分别为多少? <!DOCTYPE html> <html> <head> <meta charset=" ...