Page 3 of 3

Posted: Mon Jul 09, 2007 8:28 am
by shakil
Thanks mmonish. I want to chat with you. My id = cse0304003@yahoo.com
Thanks again.

Re: 10164 - Number Game

Posted: Sat Sep 20, 2008 8:13 am
by Darko
I must be tired or something, but I don't understand how the backtracking works here.
How should it handle inputs like this one:

Code: Select all

512
513 2 2 ... 2 2 1 1 ... 1 1 (511 2's and 511 1's)
0
?

Re: 10164 - Number Game

Posted: Sun Sep 16, 2018 4:32 pm
by metaphysis
Test data generator.

Code: Select all

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
    srand(time(NULL));

    int N[10] = {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};

    for (int cases = 1; cases <= 100; cases++)
    {
        int n = N[rand() % 10];
        cout << n << '\n';
        for (int i = 0; i < (2 * n - 1); i++)
        {
            if (i) cout << ' ';
            cout << (rand() % 1000 + 1);
        }
        cout << '\n';
    }
    cout << "0\n";

    return 0;
}