题目链接:https://cn.vjudge.net/problem/HDU-1034

水题

代码

#include <cstdio>
#include <algorithm>
int n;
long long stu[10000+5], max, min;
int func(void){
int tmp[2]={stu[0]/=2, 0}; for (int i=0; i<n; i++){
tmp[1]=stu[i+1]/=2;
stu[(i+1)%n]+=tmp[0];
tmp[0]=tmp[1]; if (stu[(i+1)%n]%2) stu[(i+1)%n]+=1;
if (i==0) max=min=stu[(i+1)%n];
max=std::max(stu[(i+1)%n], max);
min=std::min(stu[(i+1)%n], min);
}
return min!=max;
} int main(void){
while (scanf("%d", &n)==1 && n){
for (int i=0; i<n; i++){
scanf("%d", &stu[i]);
if (i==0) {min=max=stu[i];}
max=std::max(stu[i], max);
min=std::min(stu[i], min);
}
int cnt=0;
if (min!=max) while (func()) cnt++;
printf("%d %d\n", cnt+1, max);
} return 0;
}

HDU-1034 Candy Sharing Game 模拟问题(水题)的更多相关文章

  1. HDU 1034 Candy Sharing Game (模拟)

    题目链接 Problem Description A number of students sit in a circle facing their teacher in the center. Ea ...

  2. hdu 1034 Candy Sharing Game

    Candy Sharing Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  3. HDU 5867 Water problem ——(模拟,水题)

    我发这题只是想说明:有时候确实需要用水题来找找自信的~ 代码如下: #include <stdio.h> #include <algorithm> #include <s ...

  4. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  5. Candy Sharing Game(模拟搜索)

    Candy Sharing Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  6. hdu 2393:Higher Math(计算几何,水题)

    Higher Math Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. <hdu - 3999> The order of a Tree 水题 之 二叉搜索的数的先序输出

    这里是杭电hdu上的链接:http://acm.hdu.edu.cn/showproblem.php?pid=3999  Problem Description: As we know,the sha ...

  8. HDOJ/HDU 1256 画8(绞下思维~水题)

    Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...

  9. hdu 1164:Eddy's research I(水题,数学题,筛法)

    Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

随机推荐

  1. Idea配置文件的读取

    开发过程中遇到配置文件读取问题,因此记录以后运用的到. 配置文件位置: 配置文件内容: default_size = 100 grid_size = 20 delayTime = 200 配置文件读取 ...

  2. FastJSON杂项

    //通过TypeReference解决泛型的问题 List<Integer> rst = JSON.parseObject(v,new TypeReference<List<I ...

  3. 你不知道的JavaScript(十)with关键字

    with关键字在JavaScript中不太常用,用来定义一个和对象相关的作用域,在该作用域中可以访问对象的属性或方法而前面无需加上对象名,以达到简化代码的目的. <script type=&qu ...

  4. shell编程, 100文钱买100只鸡, 简单实现

    今天碰到一个有趣的问题: 群友用shell写的一个: #!/bin/bash # 百元买百鸡,每种鸡至少买一只 all= # 公鸡每只多少元 read -p '公鸡多少文一只: ' gongji # ...

  5. 【模板】扩展中国剩余定理(EXCRT)

    扩展中国剩余定理,是求解形如:$x\equiv a_{1}($ mod $b_{1})$$x\equiv a_{2}($ mod $b_{2})$$x\equiv a_{3}($ mod $b_{3} ...

  6. js常见语法错误

    “Missing semicolon.” : “缺少分号.”, “Use the function form of \”use strict\”.” : “使用标准化定义function.”, “Un ...

  7. JSON 字符串转换为 JavaScript 对象

    将数据组合成json格式的字符串var text = '{ "sites" : [' + '{ "name":"Runoob" , &quo ...

  8. [codevs3657]括号序列

    题目大意:有一列只有'(',')','[',']'构成的括号序列,求在序列中至少加上多少括号,能使该序列合法. 解题思路:区间dp. 我们以$f[i][j]$表示把区间$[i,j]$添成合法括号所需的 ...

  9. Linux 添加挂载硬盘(包含挂载大于2T以上硬盘)

    转自:http://blog.csdn.net/season_hangzhou/article/details/36423223 由于事先规划问题或者业务需求量激增,总会出现机器硬盘空间不够用的情况 ...

  10. dva基本用法

    1. npm install -g dva-cli 全局安装dva.2. dva new myApp --demo 创建dva项目.3. cd myApp npm start 启动项目.4. 定义 m ...