首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【CodeForces】Toy Army(数学)

【CodeForces】Toy Army(数学)

作者头像
FishWang
发布2025-08-26 20:21:36
发布2025-08-26 20:21:36
11000
代码可运行
举报
运行总次数:0
代码可运行

Toy Army

time limit per test

 2 seconds

memory limit per test

 256 megabytes

input

 standard input

output

 standard output

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.

Examples

input

代码语言:javascript
代码运行次数:0
运行
复制
2

output

代码语言:javascript
代码运行次数:0
运行
复制
3

input

代码语言:javascript
代码运行次数:0
运行
复制
4

output

代码语言:javascript
代码运行次数:0
运行
复制
6

Note

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.

双方人数一样,一方最后肯定要把另一方全部杀死这样结果才尽量大,如果要结果最大,自己的战损肯定也要最大,但是自己还有保留足够的人数去把对方消灭光,所以第一轮杀掉对方一半的人数,这样对方可以杀到自己一半的人。最大值就是:n + n / 2 。

代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
#include <cstdio>
int main()
{
	int n;
	while (~scanf ("%d",&n))
		printf ("%d",n+n/2);
	return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-08-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档