ZOJ 3498 Javabeans(找规律)
Javabeans
Time Limit: 2 Seconds Memory Limit: 65536 KB
Javabeans are delicious. Javaman likes to eat javabeans very much.
Javaman has n boxes of javabeans. There are exactly i javabeans in the i-th box (i = 1, 2, 3,...n). Everyday Javaman chooses an integer x. He also chooses several boxes where the numbers of javabeans are all at least x. Then he eats x javabeans in each box he has just chosen. Javaman wants to eat all the javabeans up as soon as possible. So how many days it costs for him to eat all the javabeans?
Input
There are multiple test cases. The first line of input is an integer T ≈ 100 indicating the number of test cases.
Each test case is a line of a positive integer 0 < n < 231.
Output
For each test case output the result in a single line.
Sample Input
4
1
2
3
4
Sample Output
1
2
2
3
题解:找规律
盒子数目:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17……
吃完要求的天数:
1 2 2 3 3 3 3 4 4 4 4 4 4 4 4 5 5……
Author: CAO, Peng
Contest: The 8th Zhejiang Provincial Collegiate Programming Contest
#include <iostream>
#include<cstdio>
using namespace std;
int t;
long long n;
long long ans[];
int main()
{
ans[]=;
for(int i=;i<=;i++)
ans[i]=ans[i-]*; //之前爆int了,要用long long
/*for(int i=1;i<=31;i++)
printf("%d:%lld\n",i,ans[i]);*/
while(~scanf("%d",&t))
{
for(int i=;i<=t;i++)
{
scanf("%lld",&n);
for(int j=;j<=;j++)
{
if (ans[j]<n) continue;
if (ans[j]==n) printf("%d\n",j+);
else printf("%d\n",j);
break;
}
}
}
return ;
}
ZOJ 3498 Javabeans(找规律)的更多相关文章
- ZOJ 3498 Javabeans
脑筋急转弯. 如果是偶数个,那么第一步可以是$n/2+1$位置开始到$n$都减去$n/2$,后半段就和前半段一样了. 如果是奇数个,那么第一步可以是$(n+1)/2$位置开始到$n$都减去$(n+1) ...
- 找规律 ZOJ3498 Javabeans
Javabeans are delicious. Javaman likes to eat javabeans very much. Javaman has n boxes of javabeans. ...
- 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用
转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...
- ZOJ 3622 Magic Number 打表找规律
A - Magic Number Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Subm ...
- 【ZOJ】3785 What day is that day? ——KMP 暴力打表找规律
转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是nex ...
- ZOJ 3778 Talented Chef(找规律,模拟计算,11届ACM省赛,简单)
题目链接 2014年浙江省赛C题,当时觉得难,现在想想这题真水.. 找规律: 若 最大的那个步骤数*m-总和>=0,那么答案就是 最大的那个步骤数 . 否则 就要另加上不够的数量,具体看代 ...
- zoj 3785 What day is that day? (打表找规律)
题目 思路:比赛的时候有想过找循环节,但是,打表打错了. 后来,看着过了挺多人,就急了, 看了一下别人的时间 耗时都挺长的,就以为不是找规律, 没想到真是找规律,不过,这个题的数据可能挺大的. AC代 ...
- zoj 3629 Treasure Hunt IV 打表找规律
H - Treasure Hunt IV Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu ...
- ZOJ3629 Treasure Hunt IV(找规律,推公式)
Treasure Hunt IV Time Limit: 2 Seconds Memory Limit: 65536 KB Alice is exploring the wonderland ...
随机推荐
- MySQL按时间查找
RecentMutations表的结构如图,现在的需求是需要查找到2017年09月08日前10天的变体总数: SQL语句:SELECT SUM(MutantNumber) FROM RecentMut ...
- dplyr快速入门
RStudio Blog 介绍dplyr 包已发布 (Introducing dplyr), 此包将原本 plyr 包中的 ddply() 等函数进一步分离强化, 专注接受dataframe对象, 大 ...
- Sqrt(x)
这题没多大技巧性,只是牛顿迭代法多用于数值计算,这里出现有些意外.维基上有方法说明:http://zh.wikipedia.org/wiki/牛顿法 int sqrt(int x) { if (x = ...
- java多线程总结(一)
在java中要想实现多线程,有两种手段,一种是继续Thread类,另外一种是实现Runable接口. 对于直接继承Thread的类来说,代码大致框架是: 1 2 3 4 5 6 7 8 9 10 11 ...
- DELPHI在标题栏上增加按钮
Delphi代码 unit Unit1; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Contr ...
- PAT 天梯赛 L1-003. 个位数统计
题目链接 https://www.patest.cn/contests/gplt/L1-003 题意 计算每个不同数字出现的次数 思路 可以用 MAP标记, 也可以直接用数字 存 AC代码 #incl ...
- poj1696 Space Ant
地址: 题目: Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4295 Accepted: 2697 ...
- linux 基础知识总结
1. 查看目录文件命令: 查看以f开头的文件:ll f* 查看/usr/local目录下的文件:ll /usr/local 按最后的修改的时间顺序,列出:ll -t */f* ...
- JS中函数之外不能写return
JS中return有时会遇到这种情况,具体表现为:google浏览器等浏览器可以继续执行,IE浏览器不能执行return,并且google浏览器:执行时会显示SyntaxError: Illegal ...
- 并发-HashMap和HashTable源码分析
HashMap和HashTable源码分析 参考: https://blog.csdn.net/luanlouis/article/details/41576373 http://www.cnblog ...