10659 - Fitting Text into Slides

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

Moderator: Board moderators

coze
New poster
Posts: 26
Joined: Tue Nov 27, 2007 7:56 am
Location: Japan

Re: 10659 - Fitting Text into Slides

Post by coze » Tue Oct 21, 2008 3:23 pm

Please try the following case:

input:

Code: Select all

1
1
abc abcd
24 100
your output:

Code: Select all

8
my output:

Code: Select all

No solution

DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

Re: 10659 - Fitting Text into Slides

Post by DD » Tue Oct 21, 2008 5:20 pm

coze wrote:Please try the following case:

input:

Code: Select all

1
1
abc abcd
24 100
your output:

Code: Select all

8
my output:

Code: Select all

No solution
Finall, I got A.C. Thank you, coze. I really appreciate it.
It seems that I misunderstood the definition of "wrapping" at the very beginning. :D
Have you ever...
  • Wanted to work at best companies?
  • Struggled with interview problems that could be solved in 15 minutes?
  • Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.

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

Re: 10659 - Fitting Text into Slides

Post by metaphysis » Sat Feb 10, 2018 6:12 pm

Test data generator.

Code: Select all

#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;

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

    string cs = "abcdefghijklmnopqrstyuwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=+_)(*&^%$#@!~|}{[]\\\":;\'?><,./";
    int cases = 100, cnt = cs.size();
    cout << cases << '\n';
    for (int c = 1; c <= cases; c++)
    {
        int n = rand() % 20 + 1;
        cout << n << '\n';
        for (int l = 1; l <= n; l++)
        {
            int m = rand() % 50 + 1;
            for (int i = 0; i < m; i++)
            {
                if (i) cout << ' ';
                int w = rand() % 20 + 1;
                for (int k = 0; k <= w; k++)
                    cout << cs[rand() % cnt];
            }
            cout << '\n';
        }
        int X = rand() % 2500 + 1, Y = rand() % 2500 + 1;
        cout << X << ' ' << Y << '\n';
    }

    return 0;
}

Post Reply

Return to “Volume 106 (10600-10699)”