Page 2 of 3

please help

Posted: Wed Oct 08, 2003 1:55 pm
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

Posted: Wed Oct 08, 2003 2:14 pm
by Maarten
please post in volum CIV

Posted: Fri Oct 08, 2004 9:41 am
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!

Posted: Fri Oct 08, 2004 1:42 pm
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!

Posted: Tue Jun 27, 2006 4:39 pm
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

wrong information

Posted: Sun Aug 27, 2006 5:49 pm
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.

Posted: Wed Nov 08, 2006 5:50 am
by yoshiro aoki
What is this on AC code? I am unsure of some results here:



5768678


Thanks very much

Posted: Wed Nov 08, 2006 6:23 am
by yoshiro aoki
nm.

fpavetic posted message is correct :D

Posted: Wed Nov 08, 2006 9:40 am
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

Posted: Wed Nov 08, 2006 10:28 pm
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

Posted: Thu Nov 09, 2006 1:54 am
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.

Posted: Thu Nov 09, 2006 4:45 am
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:

Posted: Thu Nov 09, 2006 7:13 am
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

Posted: Fri Nov 10, 2006 2:53 pm
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

wa 10427

Posted: Tue Jan 16, 2007 9:21 pm
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?!