Skip to content

Instantly share code, notes, and snippets.

@Tokiyomi
Last active October 21, 2022 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tokiyomi/0ac5988e71def335cdc54194dd7a86e8 to your computer and use it in GitHub Desktop.
Save Tokiyomi/0ac5988e71def335cdc54194dd7a86e8 to your computer and use it in GitHub Desktop.
powers of two in C#
// 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