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 ...
随机推荐
- 如何在sublime中使用sftp
在开发中我们通常会遇到一个问题——如何通过一款编辑器(或者IDE)便捷的同步线上代码.目前比较热门的编辑器有sublime,atom等,他们都有sftp功能,鉴于本人更喜欢用轻量级的编辑器,那我就在这 ...
- MongoDB入门(1)- MongoDB简介
什么是MongoDB NoSQL NoSQL systems are also sometimes called "Not only SQL" to emphasize that ...
- Tomcat启动报错:org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalin
Error starting ApplicationContext. To display the auto-configuration report re-run your application ...
- 【BZOJ1043】下落的圆盘 [计算几何]
下落的圆盘 Time Limit: 10 Sec Memory Limit: 162 MB[Submit][Status][Discuss] Description 有n个圆盘从天而降,后面落下的可 ...
- 【Atcoder】CODE FESTIVAL 2017 qual A D - Four Coloring
[题意]给定h,w,d,要求构造矩阵h*w满足任意两个曼哈顿距离为d的点都不同色,染四色. [算法]结论+矩阵变换 [题解] 曼哈顿距离是一个立着的正方形,不方便处理.d=|xi-xj|+|yi-yj ...
- 【BZOJ】2151 种树
[算法]贪心+堆 [题意]n个数字的序列,要求选择互不相邻的k个数字使和最大. [题解] 贪心,就是按一定顺序选取即可最优,不会反悔. 考虑第一个数字选择权值最大的,那么它相邻的两个数字就不能选择,那 ...
- 【洛谷 P1707】 刷题比赛 (矩阵加速)
题目连接 很久没写矩阵加速了,复习一下,没想到是一道小毒瘤题. 状态矩阵\(a[k],b[k],c[k],a[k+1],b[k+1],c[k+1],k,k^2,w^k,z^k,1\) 转移矩阵 0, ...
- 2、MySQL常见数据库引擎及比较?
MySQL存储引擎简介 MySQL支持数个存储引擎作为对不同表的类型的处理器.MySQL存储引擎包括处理事务安全表的引擎和处理非事务安全表的引擎: MyISAM管理非事务表.它提供高速存储和检索,以及 ...
- arch中pacman的使用
Pacman 是archlinux 下的包管理软件.它将一个简单的二进制包格式和易用的构建系统结合了起来.不管软件包是来自官方的 Arch 库还是用户自己创建,Pacman 都能方便得管理. pacm ...
- monkey测试===什么是monkey测试(系列一)转
本文转自:http://www.cnblogs.com/liu-ke/p/4353926.html Monkey工具使用 一. 什么是Monkey Monkey是Android中的一个命令行工具,可以 ...