1. 程式人生 > >【水推理】#72 A. Toy Army

【水推理】#72 A. Toy Army

A. 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 ≤ 108n 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 test(s) input
2
output
3
input
4
output
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.

這題的程式碼長度已經突破天際了……

意思是 有兩組部隊,V軍和A軍,V軍先攻擊然後輪到A軍然後輪到V軍。每個軍人每次只能打死一個敵人但是必中必死,問就這三輪攻擊最多死多少人。

死的最多即活著的最少。最後一輪攻擊後假設或者k個人,那麼他們在最後一輪攻擊的時候殺了敵人的k個人且是敵軍的最後k個人,而這k個人活著的時候殺了這半邊的k個人,再向前追溯一次就是第一次V軍攻擊的結果是:這邊有2k個人,殺了對面一些人之後對面剩下k個,因為兩邊最初都是n個人,為了讓殺的人最多,那麼2k=n,所以死了3k的人,即n的1.5倍。

讀入然後輸出1.5倍即可。

#include <iostream>
using namespace std;
// http://codeforces.com/contest/84
// Toy Army
int main()
{
	int n;	
	cin>>n;
	cout<<n/2*3;
	return 0;
}