CodeForces 143C Help Farmer
暴力枚举。
枚举最小的那个数字,不会超过$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的更多相关文章
- 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 ...
- Codeforces Round #334 (Div. 2) D. Moodular Arithmetic 环的个数
D. Moodular Arithmetic Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/60 ...
- 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 ...
- 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 ...
- 【codeforces 604D】Moodular Arithmetic
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces Round #584 D. Cow and Snacks
链接: https://codeforces.com/contest/1209/problem/D 题意: The legendary Farmer John is throwing a huge p ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
随机推荐
- (转)python编码问题
时不时总是会碰到令人头疼的编码问题,这里推荐一篇决定好文,需反复诵读之: http://www.cnblogs.com/huxi/archive/2010/12/05/1897271.html . . ...
- 51nod 1284 2 3 5 7的倍数 | 容斥原理
用容斥原理求出不满足条件的个数cnt,然后用n-cnt就得到答案了. 这里不满条件的数就是能整除2,3,5,7这些数的集合并集.要计算几个集合并集的大小,我们要先将所有单个集合的大小计算出来,然后减去 ...
- LightOJ 1340 - Story of Tomisu Ghost 阶乘分解素因子
http://www.lightoj.com/volume_showproblem.php?problem=1340 题意:问n!在b进制下至少有t个后缀零,求最大的b. 思路:很容易想到一个数通过分 ...
- Oracle数据库,忽略大小写Like模糊查询(SQL Server,MySql原理相同)
背景 在使用Oracle或者其它数据库时,使用like 关键字进行模糊查询是大家经常使用的功能,在纯中文环境中使用非常好用,还有一些通配符可以使用,但是在纯英文环境中,会出现大小需要精确匹配的问题,主 ...
- python自动开发之第二十三天(Django)
一.一大波model操作 1. 创建数据库表 # 单表 # app01_user ==> tb1 # users class User(models.Model): name = models. ...
- x64dbg
https://x64dbg.com/ https://github.com/x64dbg/x64dbg https://sourceforge.net/projects/x64dbg/files/s ...
- [New learn] 网络基础-网络操作
代码:https://github.com/xufeng79x/NETOperation 1.简介 主要记录基本的网络操作步骤,get/post关系和区别和文件上传实现. 2.准备 需要服务器端,如果 ...
- 怎么删除Windows服务
1,首先找到服务名字. 2,在cmd中进到c:下面 3,sc delete 名字. 删除成功
- 21:序列化django对象
django的序列化框架提供了一个把django对象转换成其他格式的机制,通常这些其他的格式都是基于文本的并且用于通过一个管道发送django对象,但一个序列器是可能处理任何一个格式的(基于文本或者不 ...
- 关于HTML,css3自适应屏幕,自适应宽度
设置了在不同分辨率下,显示的css样式: @media screen and (min-width:1080px){ .box{ width: 1080px;}.content{width: 1040 ...