hello_its_me's blog

By hello_its_me, 6 months ago, In English

Problem link
Hello people. I cant understand how the first player is winning on test case 1. I saw the solution used xor of nim game. But my way of thinking was counting the total number of moves in the game and decide winner based on that. But this fails on the sanple test case. Am i missing something? or is the question statement wrong.

 int n;
    cin >> n;
    int c = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (i > 1) c += (x * (i - 1));
    }
    if (c % 2)
        cout << "First\n";
    else
        cout << "Second\n";
  • Vote: I like it
  • -16
  • Vote: I do not like it