HDU-1034(简单模拟)
Candy Sharing Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Write a program which determines the number of times the teacher blows the whistle and the final number of pieces of candy for each student from the amount of candy each child starts with.
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
using namespace std;
#define INF 100000
typedef long long ll;
const int maxn=;
int a[maxn],tmp[maxn];
int main()
{
int n;
while(scanf("%d",&n)==){
if(n==) break;
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
int same,ans=,num;
while(){
same=;
for(int i=;i<=n;i++)
if(a[i]%!=) a[i]++;
for(int i=;i<=n;i++)
if(a[i]==a[i-]) {num=a[i];same++;}
else break;
if(same==n) break;
for(int i=;i<=n;i++){
a[i]=a[i]/;
tmp[i]=a[i];
}
for(int i=;i<=n;i++){
if(i==) a[i]+=tmp[n];
else a[i]+=tmp[i-];
}
ans++;
}
printf("%d %d\n",ans,num);
}
return ;
}
HDU-1034(简单模拟)的更多相关文章
- HDU 1707 简单模拟 Spring-outing Decision
Spring-outing Decision Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- hdu 5099 简单模拟(比较型号)
http://acm.hdu.edu.cn/showproblem.php?pid=5099 比较两个安卓手机型号,水题 注意点:A is actually implicit and usually ...
- HDU 1234 简单模拟题
题目很简单不多说了,我只是觉得这题目的输入方式还是很有特点的 #include <cstdio> #include <cstring> #include <algorit ...
- hdu 4858(简单模拟)
项目管理 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU 4772 Zhuge Liang's Password (简单模拟题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4772 题面: Zhuge Liang's Password Time Limit: 2000/1000 ...
- 【HDU 4452 Running Rabbits】简单模拟
两只兔子Tom和Jerry在一个n*n的格子区域跑,分别起始于(1,1)和(n,n),有各自的速度speed(格/小时).初始方向dir(E.N.W.S)和左转周期turn(小时/次). 各自每小时往 ...
- (hdu step 8.1.6)士兵队列训练问题(数据结构,简单模拟——第一次每2个去掉1个,第二次每3个去掉1个.知道队伍中的人数<=3,输出剩下的人 )
题目: 士兵队列训练问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- HDU 4509 湫湫系列故事——减肥记II (简单模拟)
题意:一天一共有1440分钟,主人公每天有n件事要做,给出这n件事开始跟结束的时间,然后让你求出,空闲的时间的总分钟数是多少. 解题报告:简单模拟,只要开个一维数组标记那个每个分钟是否是有事的就可以了 ...
- java web学习总结(二十二) -------------------简单模拟SpringMVC
在Spring MVC中,将一个普通的java类标注上Controller注解之后,再将类中的方法使用RequestMapping注解标注,那么这个普通的java类就够处理Web请求,示例代码如下: ...
- WPF简单模拟QQ登录背景动画
介绍 之所以说是简单模拟,是因为我不知道QQ登录背景动画是怎么实现的.这里是通过一些办法把它简化了,做成了类似的效果 效果图 大体思路 首先把背景看成是一个4行8列的点的阵距,X轴Y轴都是距离70.把 ...
随机推荐
- 普通pc电脑安装苹果系统mac_详细教程(精)附带所有工具下载
苹果操作系统只允许在苹果电脑上面安装和使用.和Windows不一样,要在PC上安装,需要一系列的模拟和破解.破解安装的过程很繁琐而具有挑战性,以下是安装10A432雪豹的PC安装指南,附带25张图片帮 ...
- js正则表达式及代码
//校验是否全由数字组成function isDigit(s){var patrn=/^[0-9]{1,20}$/;if (!patrn.exec(s)) return falsereturn tru ...
- [Andrew]Ext.Net常用布局(Border布局)
@(Html.X().Window().Width(600).Height(400).Layout(LayoutType.Border) .Items(p => { p.Add(Html ...
- 【原创】LoadRunner Java Vuser开发环境配置指南
1 编写目的 本文主要介绍Java运行环境的配置,同时通过编写HelloWorld程序,讲解在LoadRunner下如何开发简单的Java Vuser脚本.关于Java语言的深入学习,大家可以参考其他 ...
- 【CSS】Beginner6:Border
1.border-style:solid实线,dashed虚线,double双线,dotted点状,groove凹槽,ridge垄状,inset,outset 2.border0-width:bord ...
- oracle dblink使用
一.dblink介绍 dblink是一个单向的数据库连接,通过设置可以访问其他数据库中的数据跟使用本地数据库中数据一样的感觉,但注意是单向的dblink.例如:A建连B的dblink,A可以访问B的表 ...
- vijosP1319 数列
vijosP1319 数列 链接:https://vijos.org/p/1319 [思路] 数学. 相当于交换进制2为k. [代码] #include<iostream> using n ...
- 全面产品管理-从细微处认识"用户体验"
转载: 让我以一个故事开始本文,我觉得这个故事能概括大多数人听到“用户体验”这个术语时的想法. 我经常访问的一个财经网站给我发了一封电子邮件,请求我点击里面的一个链接,对一些信息进行审核.所以我就点了 ...
- Exception in thread "main" java.lang.IllegalArgumentException:解决方法
使用fileSystem的delete方法无法删除文件或目录 Exception in thread "main" java.lang.IllegalArgumentExcepti ...
- 恢复oracle中误删除drop掉的表
查看回收站中表 select object_name,original_name,partition_name,type,ts_name,createtime,droptime from recycl ...