10427 - Naughty Sleepy Boys
Moderator: Board moderators
please help
I
have tried my best to find out ways of
10427
Problem I
Naughty Sleepy Boys
anybody please help me to solve it.
thanks
have tried my best to find out ways of
10427
Problem I
Naughty Sleepy Boys
anybody please help me to solve it.
thanks
Hy!
zubire wrote:
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!
zubire wrote:
I found the number that contains the desired digit..then find the number.
to do this, just make a simple calculation.
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
student, EED Suceava, Romania
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:
There are some critical inputs for this problem?
Thanks!
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;
}
Thanks!
Iulian Macoveiciuc
student, EED Suceava, Romania
student, EED Suceava, Romania
for people who are going to try to solve this problem:Larry wrote:Sample:
Results: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
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
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
-
- New poster
- Posts: 3
- Joined: Sun Aug 27, 2006 5:40 pm
- Location: Dhaka
- Contact:
wrong information
Larry wrote:Sample:
your help for 10427:
Results: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
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.
-
- New poster
- Posts: 21
- Joined: Sat Oct 21, 2006 11:50 pm
- Contact:
-
- New poster
- Posts: 21
- Joined: Sat Oct 21, 2006 11:50 pm
- Contact:
-
- New poster
- Posts: 21
- Joined: Sat Oct 21, 2006 11:50 pm
- Contact:
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
!!
Anyone post some more (AC) 10427 output please?
I would appreciate very much. Thanks
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

Anyone post some more (AC) 10427 output please?
I would appreciate very much. Thanks
yoshiro (mark) aoki
-
- New poster
- Posts: 21
- Joined: Sat Oct 21, 2006 11:50 pm
- Contact:
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
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

yoshiro (mark) aoki
-
- New poster
- Posts: 21
- Joined: Sat Oct 21, 2006 11:50 pm
- Contact:
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
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

yoshiro (mark) aoki
-
- New poster
- Posts: 21
- Joined: Sat Oct 21, 2006 11:50 pm
- Contact:
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
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

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