Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace strong_number
- {
- class Program
- {
- static void Main()
- {
- int energy = int.Parse(Console.ReadLine());
- int Cur_distance;
- int won_battles = 0;
- bool Not_Enough = false;
- // every 1/3 won battle increases your energy with the number or won battles
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "End of battle") { break; }
- else
- {
- Cur_distance = Convert.ToInt32(command);
- if (energy >= Cur_distance)
- {
- energy -= Cur_distance; won_battles++;
- if (won_battles % 3 == 0) { energy += won_battles; }
- }
- else { Not_Enough = true;break; }
- }
- }
- if (Not_Enough)
- {
- Console.WriteLine($"Not enough energy! Game ends with {won_battles} won battles and {energy} energy");
- }
- else
- {
- Console.WriteLine($"Won battles: {won_battles}. Energy left: {energy}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment