Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class ChangeEvenBits
- {
- public static void Main()
- {
- checked
- {
- int count = int.Parse(Console.ReadLine());
- int[] nums = new int[count];
- for (int i = 0; i < nums.Length; i++)
- {
- nums[i] = int.Parse(Console.ReadLine());
- }
- ulong modifyingNum = ulong.Parse(Console.ReadLine());
- int countModifyedBits = 0;
- for (int i = 0; i < nums.Length; i++)
- {
- string binaryNum = Convert.ToString(nums[i], 2);
- int countBits = binaryNum.Length;
- int maxEvenBit = (countBits - 1) * 2;
- for (int bit = 0; bit <= maxEvenBit; bit += 2)
- {
- int bitValue = (int)(modifyingNum & (ulong)(1 << bit));
- if (bitValue == 0)
- {
- countModifyedBits++;
- modifyingNum |= (ulong)1 << bit;
- }
- }
- }
- Console.WriteLine(modifyingNum);
- Console.WriteLine(countModifyedBits);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement