codeforces 466B Wonder Room(思维,暴力)

题目

参考了别人的博客,百度来的博客

#include<iostream>
#include<string>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

//暴力
//a ≤ a1; b ≤ b1

int main()
{
    __int64 n,a,b;
    scanf("%I64d%I64d%I64d",&n,&a,&b);
    if(n*6<=a*b)printf("%I64d\n%I64d %I64d\n",a*b,a,b);
    else
    {
        __int64 mm=n*6,x=a,y=b,mmm=0;
        __int64 m=(__int64)sqrt(mm)+1;
        for(__int64 i=a;i<=m;i++)
        {
            __int64 yy=mm/i+(mm%i!=0);
            if(yy*i>=mm&&yy>=b)
            {
                if(!mmm)mmm=i*yy,x=i,y=yy;
                else if(yy*i<mmm)mmm=yy*i,x=i,y=yy;
            }
        }
        for(__int64 i=b;i<=m;i++)
        {
            __int64 xx=mm/i+(mm%i!=0);
            if(xx*i>=mm&&xx>=a)
            {
                if(!mmm)mmm=i*xx,y=i,x=xx;
                else if(xx*i<mmm)mmm=xx*i,y=i,x=xx;
            }
        }
        printf("%I64d\n%I64d %I64d\n",mmm,x,y);
    }
    return 0;
}

时间: 2024-10-24 18:49:25

codeforces 466B Wonder Room(思维,暴力)的相关文章

Codeforces 443A Borya and Hanabi(暴力)

题目链接:Codeforces 443A Borya and Hanabi 题目大意:有若干个牌,每张牌有花色和数字两个值,现在问说至少询问多少次才能区分出所有的牌,每次询问可以确定一种花色牌的位置,或者是一种数字牌的位置. 解题思路:暴力枚举需要问的花色和数字,210,然后枚举两两判断是否可以被区分. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const

2019ACM-ICPC沈阳网络赛-K-Guanguan&#39;s Happy water(思维+暴力)

Guanguan's Happy water 4000ms 262144K Rather than drinking happy water, Guanguan loves storing happy water. So he bought a refrigerator and stored a_iai? bottles of cola into it every day. When the storage is finished on the kk-th day, the refrigerat

Codeforces 850A - Five Dimensional Points(暴力)

原题链接:http://codeforces.com/problemset/problem/850/A 题意:有n个五维空间内的点,如果其中三个点A,B,C,向量AB,AC的夹角不大于90°,则点A是"bad"的否则是"good".题目让我们输出good的点. 思路:从2,3维空间超过5,7个点时不存在"good"的点,可以简单推知五维空间内,超过11个点时不存在"good"的点,那么点数小于11时暴力,大于11时输出0. 其

Codeforces Gym 100203G Good elements 暴力乱搞

原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf 题解 考虑暴力的复杂度是O(n^3),所以我们需要记录所有的ai+aj,如果当前考虑到了ak,那么就去前面寻找ai,使得ak-ai是我们记录过的和.整个算法的复杂度O(n^2). 代码 #include<iostream> #include<cstring> #include<cstdio> #include<

Codeforces Gym 100637G G. #TheDress 暴力

G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G Description After landing on planet i1c5l people noticed that blue and black clothes are quite popular among the locals. Each aboriginal has at least

Codeforces gym 100685 A. Ariel 暴力

A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Description King Triton really likes watching sport competitions on TV. But much more Triton likes watching live competitions. So Triton decides to set up

Codeforces 839D Winter is here - 暴力 - 容斥原理

Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers. He has created a m

CodeForces 1102C-简单的思维题

题目链接:http://codeforces.com/problemset/problem/1102/C C. Doors Breaking and Repairing time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are policeman and you are playing a game with Slavik

CodeForces 789D 欧拉路径计数,思维

CodeForces 789D 题意:n个点m条边的无向图,求经过其中m-2条边两次,剩下2条边一次的方案数有几种,如果剩下两条边的集合一样算同一种. tags: 选出两条边,其它m-2条边假想复制成两条,这样就是要求欧拉路径是否存在,即奇点个数是否为0或2. 所以该怎么选这两条边呢? 先把边分为自环边和普通边. 1.选取两条不相邻普通边,图中存在4个奇点,不满足欧拉路径条件: 2.选取两条相邻普通边,图中存在2个奇点,满足欧拉路径条件: 3.选取一条普通边一条自环,图中存在2个奇点,满足欧拉路