Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace BitShooter
- {
- class BitShooter
- {
- static void Main()
- {
- UInt64 input = UInt64.Parse(Console.ReadLine());
- string[] shot1 = Console.ReadLine().Split(' ');
- string[] shot2 = Console.ReadLine().Split(' ');
- string[] shot3 = Console.ReadLine().Split(' ');
- string initial = Convert.ToString((long)input, 2).PadLeft(64, '0');
- string[] initialArray = initial.Select(c => c.ToString()).ToArray();
- int[] shots = new int[3] { Convert.ToInt32(shot1[0]), Convert.ToInt32(shot2[0]),
- Convert.ToInt32(shot3[0]) };
- int[] ranges = new int[3] { Convert.ToInt32(shot1[1]), Convert.ToInt32(shot2[1]),
- Convert.ToInt32(shot3[1]) };
- //foreach (var item in initialArray)
- //{
- // Console.Write(item);
- //}
- //Console.WriteLine();
- Array.Reverse(initialArray);
- for (int x = 0; x < 3; x++)
- {
- for (int i = 0; i < initialArray.Length; i++)
- {
- if (i == shots[x])
- {
- if (i - (ranges[x] / 2) < 0)
- {
- //int temp = i - Convert.ToInt32(shot1[1]) / 2;
- for (int j = 0; j <= shots[x]+ranges[x]/2; j++)
- {
- initialArray[j] = "0";
- }
- }
- else if (i + ranges[x] / 2 > 64)
- {
- //int temp = i - Convert.ToInt32(shot1[1]) / 2;
- for (int j = shots[x] - ranges[x] / 2; j < 64; j++)
- {
- initialArray[j] = "0";
- }
- }
- else
- {
- for (int j = i - (ranges[x] / 2); j < i - (ranges[x] / 2) + ranges[x]; j++)
- {
- initialArray[j] = "0";
- }
- }
- }
- }
- }
- Array.Reverse(initialArray);
- int leftcount = 0;
- int rightcount = 0;
- for (int i = 0; i < initialArray.Length; i++)
- {
- if (i < 32)
- {
- if (initialArray[i] == "1")
- {
- leftcount++;
- }
- }
- else if(i >=32 && i < initialArray.Length)
- {
- if (initialArray[i] == "1")
- {
- rightcount++;
- }
- }
- }
- //foreach (var item in initialArray)
- //{
- // Console.Write(item);
- //}
- Console.WriteLine("left: " + leftcount);
- Console.WriteLine("right: " + rightcount);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment