哈理工OJ 2111 Apple(简单模拟)
来源:互联网 发布:广告算法工程师面试题 编辑:程序博客网 时间:2024/04/29 10:17
题目链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=2111
Apple
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 114(71 users) Total Accepted: 75(69 users) Rating: Special Judge: No
Description
There is a table, on which some plates were put in a circle. Some apples were put in the plates.
Let's play a game.For each plate, separate the apples into two parts. For example if a plate containing M apples, put M/2 apples into the left-hand plate and the rest to the righthand plate. Note that if M is a odd number, then M/2 equals (M-1)/2. Plates are numbered from 1 to N in counter-clockwise. The left-hand plate is the plate whose number is smaller. The left-hand plate of plate numbered 1 is the plate numbered N. Given the number of apples in each plate(1,2,...N), output the the number of apples in each plate when game is over.
Input
The input contains multiple test case. The first line of each case contains a integer N, the number of plates on the table, followed by N integers a1, a2, …, aN representing the number of apples in the plates(1,2,…N).
1<=N<=10000, 1<=ai<=100.
Output
For each test case print the number of apples in each plate(from numbered 1 to N) when game is over.
Sample Input
5
1 2 3 4 5
10
1 2 3 4 5 6 7 8 9 10
Sample Output
4 2 3 4 2
6 2 3 4 5 6 7 8 9 5
Source
ACM-ICPC黑龙江省第九届大学生程序设计竞赛选拔赛(2)
【中文题意】n个人围成1个圈,1的左边是n,就是每个人有一定的苹果数,每个人的苹果的一半给左边的人,剩下的给右边的人,问你最后每个人有多少苹果。
【思路分析】直接模拟就好了。
【AC代码】
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<stack>#include<queue>using namespace std;#define LL long longint a[10005],re[10005];int main(){ int n; while(~scanf("%d",&n)) { for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } re[1]=a[2]/2+a[n]-a[n]/2; for(int i=2;i<=n-1;i++) { re[i]=(a[i-1]-a[i-1]/2)+a[i+1]/2; } re[n]=a[n-1]-a[n-1]/2+a[1]/2; for(int i=1;i<n;i++) { printf("%d ",re[i]); } printf("%d\n",re[n]); } return 0;}
- 哈理工OJ 2111 Apple(简单模拟)
- 哈理工OJ 1031 _OOOO_ Problem(简单模拟问题)
- 哈理工OJ 1045 Draw A Square(简单模拟)
- 哈理工OJ 1380 Vagaa, eMule and Apple(水题)
- hrbust 哈理工oj 1020 Robot Motion【简单模拟】
- 哈理工OJ 1562 字符统计器(水模拟)
- hrbust 哈理工oj 1330 邂逅【模拟】
- 哈理工 OJ 2215 Angle(简单的思维题)
- 哈理工OJ 2214 Judge(简单的数学题)
- 哈理工OJ 1124 Final Destination(简单递推)
- 哈理工OJ 1986 大悲咒(简单递推)
- 哈理工 1178 分数加减(简单的模拟)
- 哈理工OJ 1580 Tell me the length(模拟+找规律)
- 哈理工OJ 1020 Robot Motion(模拟+队列【类似小搜索】)
- 哈理工OJ 1176 小陈老师、雪人(排序+优先队列模拟)
- 哈理工OJ 1575 Calculate the day-1(水模拟)
- 哈理工OJ 2255 镇守府海域·镇守府近海(模拟题目)
- hrbust/哈理工oj Contest Print Server【模拟】
- Node.js视频教程
- 396. Rotate Function
- 银行转账问题探究-java中synchronized关键字用法.
- ELK采集之nginx 之高德地图出城市IP分布图
- CPU为什么选择导热硅脂而不是牙膏
- 哈理工OJ 2111 Apple(简单模拟)
- 大神班JAVA第一期
- 小程序-开发入门
- http和socket之长连接和短连接区别
- iOS添加字体库
- 创业多想一秒,做事少磕十年
- 在less上写css3动画
- python2.7 遇到的字符集问题
- android studio 下的LitePal 混淆处理