10164 - Number Game

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

shakil
Learning poster
Posts: 74
Joined: Sat Jul 15, 2006 6:28 am
Location: CUET , bangladesh
Contact:

Post by shakil » Mon Jul 09, 2007 8:28 am

Thanks mmonish. I want to chat with you. My id = cse0304003@yahoo.com
Thanks again.
SHAKIL

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Re: 10164 - Number Game

Post by Darko » Sat Sep 20, 2008 8:13 am

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
?

metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 10164 - Number Game

Post by metaphysis » Sun Sep 16, 2018 4:32 pm

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;
}

Post Reply

Return to “Volume 101 (10100-10199)”