10427 - Naughty Sleepy Boys

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

Moderator: Board moderators

nikhil
New poster
Posts: 11
Joined: Wed Oct 08, 2003 1:37 pm

please help

Post by nikhil »

I
have tried my best to find out ways of
10427
Problem I
Naughty Sleepy Boys
anybody please help me to solve it.
thanks

Maarten
Experienced poster
Posts: 108
Joined: Sat Sep 27, 2003 5:24 pm

Post by Maarten »

please post in volum CIV

iulianM
New poster
Posts: 2
Joined: Fri Oct 08, 2004 9:33 am
Location: Suceava, Romania
Contact:

Post by iulianM »

Hy!

zubire wrote:
then find the number.

to do this, just make a simple calculation.
I found the number that contains the desired digit..
But i have problems to get the rigth digit from this number.

I got WA.

Can you tell me please how do this in the best way ?

Thanks!
Iulian Macoveiciuc
student, EED Suceava, Romania

iulianM
New poster
Posts: 2
Joined: Fri Oct 08, 2004 9:33 am
Location: Suceava, Romania
Contact:

Post by iulianM »

This is my code. I got WA for this, but I don't know why.
I tested the sample input posted by Larry and the output of my program is the same. I think ther's something wrong where I try to get the desired digit from the number that contains it.

Below is my code. Maybe is someone who can help me to find the mistake:

Code: Select all

/* Naughty sleepy boys (10427) */
#include <stdio.h>

char string[20];
int i, rem, m;
long long int n, class[9], maxValue[9], j, k, before, offset;

int main(void)  {
    class[0] = 9L;
    class[1] = 180L;
    class[2] = 2700L;
    class[3] = 36000L;
    class[4] = 450000L;
    class[5] = 5400000L;
    class[6] = 63000000L;
    class[7] = 720000000L;
    class[8] = 8100000000L;

    maxValue[0] = 9L;
    maxValue[1] = 99L;
    maxValue[2] = 999L;
    maxValue[3] = 9999L;
    maxValue[4] = 99999L;
    maxValue[5] = 999999L;
    maxValue[6] = 9999999L;
    maxValue[7] = 99999999L;
    maxValue[8] = 999999999L;

    while(scanf("%ld", &n) != EOF)      {
         for(i = 0; i < 9; i++)
                if(n < class[i])  {
	      if( n <  10)
	          printf("%ld\n", n);
	      else
	      {  
                          before = 0;
	          for(m = 0; m < i; m++)
                                before += class[m];

	          offset = n - before;

	          k = offset / (i+1);
	          if(offset % (i+1))
                                k++;

	          j = maxValue[i-1] + k;
	          sprintf(string, "%ld", j);
	          rem = offset%(i+1);

	          if(rem == 0 && i == 1)
                                rem = 2;

	          if(rem == 0)
                                rem++;

	          printf("%c\n", string[rem-1]);
                     }
                     break;
               }
      }

      return 0;
}
There are some critical inputs for this problem?

Thanks!
Iulian Macoveiciuc
student, EED Suceava, Romania

fpavetic
Learning poster
Posts: 51
Joined: Sat Mar 04, 2006 8:00 pm

Post by fpavetic »

Larry wrote:Sample:

Code: Select all

3
9
10
11
10000
50000
1000000000
5135136
351357
88456345
34135141
513341
13516167
6252345
767657
613566
5768678
63453
253478
95465462
513513511
5151356786
875673562
Results:

Code: Select all

3
9
1
0
7
1
7
4
4
1
7
0
2
0
4
0
6
1
1
2
0
5
6
for people who are going to try to solve this problem:
my AC program outputs

Code: Select all

3
9
1
0
7
1
1
4
4
1
7
0
2
0
4
0
6
1
1
2
0
8
6

riyad_csedu
New poster
Posts: 3
Joined: Sun Aug 27, 2006 5:40 pm
Location: Dhaka
Contact:

wrong information

Post by riyad_csedu »

Larry wrote:Sample:

your help for 10427:

Code: Select all

3
9
10
11
10000
50000
1000000000
5135136
351357
88456345
34135141
513341
13516167
6252345
767657
613566
5768678
63453
253478
95465462
513513511
5151356786
875673562
Results:

Code: Select all

3
9
1
0
7
1
7
4
4
1
7
0
2
0
4
0
6
1
1
2
0
5
6


/****************/

your output for 1000000000 and 5151356786 are wrong !
please verify yourself before help someone.

yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

What is this on AC code? I am unsure of some results here:



5768678


Thanks very much
yoshiro (mark) aoki

yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

nm.

fpavetic posted message is correct :D
yoshiro (mark) aoki

yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

My code passes all my present tests and all those posted on this site, yet I get WA:x

I had to reduce the largest number I could resolve to 99,999,999
so the Judge could compile it. Its ok, because 10427 says
"N<100,000,000".

But I can easily resolve the much larger test numbers found on this site.

The Judge is being a pain :evil:!!


Anyone post some more (AC) 10427 output please?

I would appreciate very much. Thanks
yoshiro (mark) aoki

yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

I wrote a program that writes the series (1,2,3,4,...,99999999) to a disk file.

I then access using "file.seekg(iIndex)".
So, I have all answers for the entire test range.

But after checking 50 random points there is no failure as yet.
It must be a very odd bug, to pass so many test cases and still get WA.

I will connect these two programs together so that all 99999999 values may be checked. It sounds like a fun project to do for investigation :D
yoshiro (mark) aoki

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

Post by Darko »

What language are you using? If it's Pascal or Java, WA might mean RTE. Sometimes input here contains spaces at the end of lines, blank lines, that sort of thing - so it depends on how you parse the numbers, too.

yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

Im using C++.

The problem didn't say much about formatting, so I have no idea.
I made the output like in the problem, and expect PE if the Judge gets picky about spacing.

I finished the named-pipe server for my sequence db, and a client. So, tomorrow I will test my pgm on all possibilities if I get more time. Its fun little project :)


Someone mentioned I might be opening new threads, but this solution is single threaded. Its not like its a DCOM object

I hope its some exotic bug in my code...instead of some dumb space :roll:
yoshiro (mark) aoki

yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

I finished the server.
So, the table values are comparing with calculated values now on my WA code.

Its at 320,000 now and should be done in 92 hours.

I suspect the problem may be that the judge expected a space (or not) from the beginning, or maybe a bug on my part in higher numbers. Who knows.

Its was a good excuse to write more code :P
yoshiro (mark) aoki

yoshiro aoki
New poster
Posts: 21
Joined: Sat Oct 21, 2006 11:50 pm
Contact:

Post by yoshiro aoki »

My 10427 code passed 41 million test cases by today.

So, I looked at Judge email and I see it is not the code I submitted to the Judge for the
yoshiro (mark) aoki

WR
Experienced poster
Posts: 145
Joined: Thu Nov 27, 2003 9:46 am

wa 10427

Post by WR »

Hi,

all test cases passed (same results as fpavetic), even checked all possible cases like yoshiro aoki, but still wrong answer.

language used is c. anybody has an idea?!

Post Reply

Return to “Volume 104 (10400-10499)”