Thursday, September 3, 2015

UVa 12461 - Airplane

Accepted date: 2015-09-03
Ranking (as of 2015-09-03): 63 out of 769
Language: C++

/*
  UVa 12461 - Airplane

  To build using Visual Studio 2012:
    cl -EHsc -O2 UVa_12461_Airplane.cpp
*/

/*
    probability = 2^(n - 2) / 2^(n - 1) = 1/2

n: 2
  1 2
  2 1 *
                  1/2
n: 3
  1 2 3
  2 1 3
  2 3 1 *
  3 2 1 *
                  2/4

n: 4
  1 2 3 4
  2 1 3 4
  2 3 1 4
  2 3 4 1 *
  2 4 3 1 *
  3 2 1 4
  3 2 4 1 *
  4 2 3 1 *
                  4/8

n: 5
  1 2 3 4 5
  2 1 3 4 5
  2 3 1 4 5
  2 3 4 1 5
  2 3 4 5 1 *
  2 3 5 4 1 *
  2 4 3 1 5
  2 4 3 5 1 *
  2 5 3 4 1 *
  3 2 1 4 5
  3 2 4 1 5
  3 2 4 5 1 *
  3 2 5 4 1 *
  4 2 3 1 5
  4 2 3 5 1 *
  5 2 3 4 1 *
                  8/16

n: 6
  1 2 3 4 5 6
  2 1 3 4 5 6
  2 3 1 4 5 6
  2 3 4 1 5 6
  2 3 4 5 1 6
  2 3 4 5 6 1 *
  2 3 4 6 5 1 *
  2 3 5 4 1 6
  2 3 5 4 6 1 *
  2 3 6 4 5 1 *
  2 4 3 1 5 6
  2 4 3 5 1 6
  2 4 3 5 6 1 *
  2 4 3 6 5 1 *
  2 5 3 4 1 6
  2 5 3 4 6 1 *
  2 6 3 4 5 1 *
  3 2 1 4 5 6
  3 2 4 1 5 6
  3 2 4 5 1 6
  3 2 4 5 6 1 *
  3 2 4 6 5 1 *
  3 2 5 4 1 6
  3 2 5 4 6 1 *
  3 2 6 4 5 1 *
  4 2 3 1 5 6
  4 2 3 5 1 6
  4 2 3 5 6 1 *
  4 2 3 6 5 1 *
  5 2 3 4 1 6
  5 2 3 4 6 1 *
  6 2 3 4 5 1 *
                  16/32

*/

#include <cstdio>

int main()
{
  while (true) {
    int n;
    scanf("%d", &n);
    if (!n)
      break;
    puts("1/2");
  }
  return 0;
}

No comments:

Post a Comment