Toy Army
2016-05-16 22:00
309 查看
Description
The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows.
There are two armies on the playing field each of which consists of n men (n is always even). The current player specifies for
each of her soldiers an enemy's soldier he will shoot (a target) and then all the player's soldiers shot simultaneously. This is a game world, and so each soldier shoots perfectly, that is he absolutely always hits the specified target. If an enemy soldier
is hit, he will surely die. It may happen that several soldiers had been indicated the same target. Killed soldiers do not participate in the game anymore.
The game "GAGA" consists of three steps: first Valera makes a move, then Arcady, then Valera again and the game ends.
You are asked to calculate the maximum total number of soldiers that may be killed during the game.
Input
The input data consist of a single integer n (2 ≤ n ≤ 108, n is
even). Please note that before the game starts there are 2n soldiers on the fields.
Output
Print a single number — a maximum total number of soldiers that could be killed in the course of the game in three turns.
Sample Input
Input
Output
Input
Output
Hint
The first sample test:
1) Valera's soldiers 1 and 2 shoot at Arcady's soldier 1.
2) Arcady's soldier 2 shoots at Valera's soldier 1.
3) Valera's soldier 1 shoots at Arcady's soldier 2.
There are 3 soldiers killed in total: Valera's soldier 1 and Arcady's soldiers 1 and 2.
题意:
甲乙分别有相等数目的士兵,两人总共只能射击3次,求被射击的士兵数目的最大值。
每次射击对方现有士兵数的一半时,被射击的士兵数目最大。弄清题意之后,代码也就是撒撒水的事!!
代码如下
#include<stdio.h>
int main()
{
int n,maxnum;
scanf("%d",&n);
maxnum=(n/2)*3;
printf("%d",maxnum);
}
The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows.
There are two armies on the playing field each of which consists of n men (n is always even). The current player specifies for
each of her soldiers an enemy's soldier he will shoot (a target) and then all the player's soldiers shot simultaneously. This is a game world, and so each soldier shoots perfectly, that is he absolutely always hits the specified target. If an enemy soldier
is hit, he will surely die. It may happen that several soldiers had been indicated the same target. Killed soldiers do not participate in the game anymore.
The game "GAGA" consists of three steps: first Valera makes a move, then Arcady, then Valera again and the game ends.
You are asked to calculate the maximum total number of soldiers that may be killed during the game.
Input
The input data consist of a single integer n (2 ≤ n ≤ 108, n is
even). Please note that before the game starts there are 2n soldiers on the fields.
Output
Print a single number — a maximum total number of soldiers that could be killed in the course of the game in three turns.
Sample Input
Input
2
Output
3
Input
4
Output
6
Hint
The first sample test:
1) Valera's soldiers 1 and 2 shoot at Arcady's soldier 1.
2) Arcady's soldier 2 shoots at Valera's soldier 1.
3) Valera's soldier 1 shoots at Arcady's soldier 2.
There are 3 soldiers killed in total: Valera's soldier 1 and Arcady's soldiers 1 and 2.
题意:
甲乙分别有相等数目的士兵,两人总共只能射击3次,求被射击的士兵数目的最大值。
每次射击对方现有士兵数的一半时,被射击的士兵数目最大。弄清题意之后,代码也就是撒撒水的事!!
代码如下
#include<stdio.h>
int main()
{
int n,maxnum;
scanf("%d",&n);
maxnum=(n/2)*3;
printf("%d",maxnum);
}
相关文章推荐
- 第十三周学习进度条
- HDU 5365 Run (思维计算几何)
- 1000以内的回文素数
- 高效使用xcode
- leetcode(10),Roman to Integer(python)
- BZOJ_1507_Editor_[NOI2003]_(Splay)
- Viewpager+Fragment 实现滑动切换显示内容
- android开发第一次心的
- 5.swift关键字和符号
- 数据类型包装类,String,对象的复制
- 欢迎使用CSDN-markdown编辑器
- ./configure详解
- JAVA学习笔记整理一(基础知识)
- Problem-D
- 18-Python网络编程
- 学生信息管理系统——指针和链表的应用
- 机器学习(一)------- 线性回归(Linear regression )
- SpringMVC注解@RequestParam全面解析---打酱油的日子
- 二分答案方法、
- 中国UTM分区