暴力枚举。

枚举最小的那个数字,不会超过$1000$,剩下的两个数字根号的效率枚举一下即可。

#include<bits/stdc++.h>
using namespace std; long long n;
long long ansMin,ansMax; int main()
{
scanf("%lld",&n); ansMin=1e18;
ansMax=-; long long p = (long long)pow(1.0*n,1.0/);
p++; for(long long x1=;x1<=p;x1++)
{
if(n%x1) continue;
long long s = n/x1;
for(long long x2=;x2*x2<=s;x2++)
{
if(s%x2) continue;
long long x3=s/x2; long long A,B,C; A=x1+; B=x2+; C=x3+; ansMin=min(ansMin,A*B*C-n);
ansMax=max(ansMax,A*B*C-n); A=x2+; B=x1+; C=x3+; ansMin=min(ansMin,A*B*C-n);
ansMax=max(ansMax,A*B*C-n); A=x3+; B=x2+; C=x1+; ansMin=min(ansMin,A*B*C-n);
ansMax=max(ansMax,A*B*C-n);
}
} printf("%lld %lld\n",ansMin,ansMax); return ;
}

CodeForces 143C Help Farmer的更多相关文章

  1. Codeforces Round #102 (Div. 1) A. Help Farmer 暴力分解

    A. Help Farmer 题目连接: http://www.codeforces.com/contest/142/problem/A Description Once upon a time in ...

  2. Codeforces Round #334 (Div. 2) D. Moodular Arithmetic 环的个数

    D. Moodular Arithmetic Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/60 ...

  3. Codeforces Round #346 (Div. 2) F. Polycarp and Hay 并查集 bfs

    F. Polycarp and Hay 题目连接: http://www.codeforces.com/contest/659/problem/F Description The farmer Pol ...

  4. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)A. Protect Sheep

    http://codeforces.com/contest/948/problem/A   A. Protect Sheep Bob is a farmer. He has a large pastu ...

  5. 【codeforces 604D】Moodular Arithmetic

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. Codeforces Round #584 D. Cow and Snacks

    链接: https://codeforces.com/contest/1209/problem/D 题意: The legendary Farmer John is throwing a huge p ...

  7. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  8. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  9. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

随机推荐

  1. Mybatis(4) 映射文件-参数处理

    参数处理: 单参数处理: mybatis 不会做任何特殊处理. #{key} : key 可以写任何字段取出参数值. 测试方法: mapper接口: mapper.xml: 控制台: 多参数处理: m ...

  2. telnet退出

    windows下退出telnet:可以参考下面linux退出,也可以直接关闭窗口. linux退出telnet: 1.输入ctrl+]:显示出telnet>. 2.此时可以输入?,查看可以使用的 ...

  3. jQuery中val()、text()、html()之间的差别

    一.括号里没有值时表示取值    val获取表单中的值: text获取对象中的文本内容,不包含html标签: html获取对象中的内容,包括html标签 <!DOCTYPE HTML> & ...

  4. 【hdu3033】分组背包(每组最少选一个)

    [题意] 有S款运动鞋,一个n件,总钱数为m,求不超过总钱数且每款鞋子至少买一双的情况下,使价值最大.如果有一款买不到,就输出“Impossible". 1<=N<=100  1 ...

  5. 【BZOJ】1589: [Usaco2008 Dec]Trick or Treat on the Farm 采集糖果

    [算法]基环树DP [题意]给定若干有向基环树,每个点能走的最远路径长度. [题解] 参考:[BZOJ1589]Trick or Treat on the Farm 基环树裸DP by 空灰冰魂 考虑 ...

  6. 【BZOJ】1610: [Usaco2008 Feb]Line连线游戏

    [算法]计算几何 [题解]计算所有斜率排序去重. 实数判断相等用fabs(...)≤eps. ★斜率题一定要注意斜率不存在的情况!!! 其实我觉得这份代码可以hack的…… #include<c ...

  7. Spring 路由地址的基本使用

    1.下面是spring的使用基本框架连接 https://www.cnblogs.com/HD/p/4103239.html

  8. tensorflow常用函数解析

    一.tf.transpose函数的用法 tf.transpose(input, [dimension_1, dimenaion_2,..,dimension_n]):这个函数主要适用于交换输入张量的不 ...

  9. 树莓派开启smb

    1.安装smb apt-get install samba samba-common-bin 2.修改/etc/samba/smb.conf配置 设置使用系统用户登入 增加smb访问文件夹 [shar ...

  10. GNU Readline 库及编程简介【转】

    转自:https://www.cnblogs.com/hazir/p/instruction_to_readline.html 用过 Bash 命令行的一定知道,Bash 有几个特性: TAB 键可以 ...