Last active
October 21, 2022 22:17
-
-
Save Tokiyomi/0ac5988e71def335cdc54194dd7a86e8 to your computer and use it in GitHub Desktop.
powers of two in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Main function in C# | |
static void Main(string[] args) | |
{ | |
long T = Convert.ToInt64(Console.ReadLine()); // Read # of Cases | |
for (int i = 0; i < T; i++){ | |
int N = Convert.ToInt32(Console.ReadLine()); // Read N | |
if (N == -1) { // if N==-1, end program | |
break; | |
} | |
// Generate our A set of powers of two | |
var A = powers_of_two(N); | |
// Print A set in terminal | |
foreach(var item in A) | |
{ | |
Console.Write(item + " "); | |
} | |
Console.WriteLine(); | |
// Read B set from terminal | |
var B_string = Console.ReadLine(); | |
List<long> B = B_string.Split(' ').ToList().Select(x => Convert.ToInt64(x)).ToList(); | |
// Solve Case | |
var C = solve_sum(A,B); | |
// Print result | |
foreach(var item in C) | |
{ | |
Console.Write(item + " "); | |
} | |
Console.WriteLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment