hdu 1399(水题)
Starship Hakodate-maru
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 751 Accepted Submission(s): 518
surveyor starship Hakodate-maru is famous for her two fuel containers
with unbounded capacities. They hold the same type of atomic fuel balls.
There, however, is an inconvenience. The shapes of the fuel
containers #1 and #2 are always cubic and regular tetrahedral
respectively. Both of the fuel containers should be either empty or
filled according to their shapes. Otherwise, the fuel balls become
extremely unstable and may explode in the fuel containers. Thus, the
number of fuel balls for the container #1 should be a cubic number (n^3
for some n = 0, 1, 2, 3, ...) and that for the container #2 should be a
tetrahedral number (n(n+1)(n+2)/6 for some n = 0, 1, 2, 3, ...).
Hakodate-maru
is now at the star base Goryokaku preparing for the next mission to
create a precise and detailed chart of stars and interstellar matters.
Both of the fuel containers are now empty. Commander Parus of Goryokaku
will soon send a message to Captain Future of Hakodate-maru on how many
fuel balls Goryokaku can supply. Captain Future should quickly answer to
Commander Parus on how many fuel balls she requests before her ship
leaves Goryokaku. Of course, Captain Future and her officers want as
many fuel balls as possible.
For example, consider the case
Commander Parus offers 151200 fuel balls. If only the fuel container #1
were available (i.e. if the fuel container #2 were unavailable), at most
148877 fuel balls could be put into the fuel container since 148877 =
53 * 53 * 53 < 151200 < 54 * 54 * 54. If only the fuel container
#2 were available, at most 147440 fuel balls could be put into the fuel
container since 147440 = 95 * 96 * 97 / 6 < 151200 < 96 * 97 * 98 /
6. Using both of the fuel containers #1 and #2, 151200 fuel balls can
be put into the fuel containers since 151200 = 39 * 39 * 39 + 81 * 82 *
83 / 6. In this case, Captain Future's answer should be "151200".
Commander
Parus's offer cannot be greater than 151200 because of the capacity of
the fuel storages of Goryokaku. Captain Future and her officers know
that well.
You are a fuel engineer assigned to Hakodate-maru.
Your duty today is to help Captain Future with calculating the number of
fuel balls she should request.
input is a sequence of at most 1024 positive integers. Each line
contains a single integer. The sequence is followed by a zero, which
indicates the end of data and should not be treated as input. You may
assume that none of the input integers is greater than 151200.
output is composed of lines, each containing a single integer. Each
output integer should be the greatest integer that is the sum of a
nonnegative cubic number and a nonnegative tetrahedral number and that
is not greater than the corresponding input number. No other characters
should appear in the output.
64
50
20
151200
0
64
47
20
151200
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <iostream>
#include <map>
using namespace std;
int n;
int main()
{
while(scanf("%d",&n)!=EOF,n){
int ans = ,ans1 = ;
for(int i=;i<=;i++){
if(i*i*i>n) break;
ans = i;
}
for(int i=;i<=;i++){
if(i*(i+)*(i+)>*n) break;
ans1 = i;
}
int res = ;
for(int i=;i<=ans+;i++){
for(int j=;j<=ans1+;j++){
if(i*i*i+j*(j+)*(j+)/>n) {
break;
}
res = max(res,i*i*i+j*(j+)*(j+)/);
}
}
printf("%d\n",res);
}
}
hdu 1399(水题)的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
- hdu 2710 水题
题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...
- Dijkstra算法---HDU 2544 水题(模板)
/* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...
- hdu 5162(水题)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5038 水题 可是题意坑
http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数 这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心 If not all ...
随机推荐
- App.config的典型应用
----.net中XML的典型应用 第一种修改方式: 添加xml节点figguration内容, 微软提供了一种方案来读取connectionStrings里的内容 这样就可以拿到连接sql serv ...
- bzoj2165: 大楼(倍增floyd)
题目大意:一个有向图,n(<=100)个点求一条长度>=m(<=10^18)的路径最少经过几条边. 一开始以为是矩乘,蓝鹅当时还没开始写,所以好像给CYC安利错了嘿嘿嘿QWQ 第一眼 ...
- Educational Codeforces Round 6 B
B. Grandfather Dovlet’s calculator time limit per test 1 second memory limit per test 256 megabytes ...
- jQuery无法获取隐藏元素(display:none)宽度(width)和高度(height)的新解决方案
用jQuery写一个通过点击左右图标来翻阅图片的小插件,写好后测试可以正常运行,但是放到Tab中后发现只有第一个Tab中的代码能够正常运行,其它全部罢工了. 用Chrome自带的开发工具一查,发现罢工 ...
- [技巧篇]07.JSON.parse() 和 JSON.stringify()
JSON.parse() 用于从一个字符串中解析出json对象,如 var str = '{"name":"huangxiaojian","age&q ...
- js处理时间的那些事
我们在实际需求中一般需要对时间进行相应的出来,比如:对时间串的拆分显示,两个时间差的求值显示等. 时间拆分: 一般对于这种处理我们使用正则表示式: 正则表达式拆分时间: var date = data ...
- Merge Query
1. Oracle: "MERGE into MHGROUP.proj_access m using dual on " + "(PRJ_ID = '" + W ...
- 【BZOJ1038】【ZJOI2008】瞭望塔 [模拟退火]
瞭望塔 Time Limit: 10 Sec Memory Limit: 162 MB[Submit][Status][Discuss] Description 致力于建设全国示范和谐小村庄的H村村 ...
- 【BZOJ】3779 重组病毒
[算法]Link-Cut Tree+线段树(维护DFS序) [题解]整整三天……T_T 这篇题解比较资瓷:permui 这道题虽然树形态没有变化,但用lct写的原因在于把题目中的操作一进行了神转化:每 ...
- 【BZOJ】1552/3506 [Cerc2007]robotic sort
[算法]splay [题解] splay维护序列,用权值(离散化)作为编号.每次找第i小的话直接找对应编号splay即可. 但是这样splay没有下传翻转标记?直接暴力找到路径然后从根到改结点push ...