Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Bounce
- {
- using System;
- using System.Linq;
- using System.Numerics;
- class Program
- {
- static void Main()
- {
- int[] sizes = Console.ReadLine().Split().Select(int.Parse).ToArray();
- if (sizes.Contains(1))
- {
- Console.WriteLine(1);
- return;
- }
- bool rowUp = true;
- bool colUp = true;
- BigInteger sum = 1;
- for (int i = 0; i < sizes[0];)
- {
- for (int j = 0; j < sizes[1];)
- {
- if (rowUp)
- {
- i++;
- if (i == sizes[0] - 1)
- rowUp = false;
- }
- else
- {
- i--;
- if (i == 0)
- rowUp = true;
- }
- if (colUp)
- {
- j++;
- if (j == sizes[1] - 1)
- colUp = false;
- }
- else
- {
- j--;
- if (j == 0)
- colUp = true;
- }
- sum += (BigInteger)Math.Pow(2, i + j);
- if ((i == 0 && j == 0) ||
- (i == 0 && j == sizes[1] - 1) ||
- (i == sizes[0] - 1 && j == 0) ||
- (i == sizes[0] - 1 && j == sizes[1] - 1))
- {
- Console.WriteLine(sum);
- return;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement