## 10127 - Ones

Moderator: Board moderators

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:
For the input n=9981, the expected output from your program is 9972.

Do you think a double type (with its mere 53 bits of precision) is able to _accurately_ handle numbers of order 10^9972?
Change the approach.

Navid666
New poster
Posts: 7
Joined: Tue Jul 26, 2005 8:06 pm
Contact:
i changed my approach and got accept , you were right we do not need to work with numbers of one's, we can use mods :D
=;GOOD LUCK=;
NAvidOP

JackDaniels
New poster
Posts: 8
Joined: Mon Aug 11, 2003 4:51 pm
Location: Suceava, Romania

### 10127 sugestion

Hi everybody.

Here is my suggestion:
-all types you need is int and double
-for solving here is some info:
You must compute the arithmetic mean (AM) for the spendings of the students. And there are 3 cases:
1. If the AM is something like ddd.005 then you must compute the minimum exchange sums for upper and lower spendings than ddd.000 first and for ddd.010 secondly. You choose the minimum from these two, but if one of the sums is zero then you choose the other one which might be greater than zero.
2. If the AM is something like ddd.qqq slower than ddd.005 then this calculus is done for ddd.000
3. Else if AM is like ddd.qqq larger than ddd.005 then the calculus is done for ddd.010. And there is okey.
Good luck.

So, someone showed some correct test cases:

Code: Select all

``````3
10.00
20.00
30.00
4
15.00
15.01
3.00
3.01
5
5000.00
11.11
11.11
11.11
11.11
3
0.01
0.03
0.03
4
25.00
25.00
25.00
28.00
3
10.01
15.25
18.96
4
25.03
25.00
25.00
25.00
0

\$10.00
\$11.99
\$3991.11
\$0.01
\$2.25
\$4.73
\$0.02
``````
For the third test case i am in doubt that answer is correct so the solution provided by UVA judge is wrong. My answer is: 3991.08 and that is so because we can take the AM as 1008.880 firstly (and the answer is 3991.08 -this is the minimum exchange sum) and as 1008.890 secondly(for this the answer is 3991.11 -surely larger than previous one). The computed value for AM is initially 1008.888000 but I say it is correct to compute for both roundings and then choose the minimum.
I please UVA to correct this in the future!
Nothing is lost because everything is transforming.

Carlos
Posts: 1286
Joined: Sat Oct 13, 2001 2:00 am
Contact:
you didn't understand the problem description. Try to make a "balance" and you'll find the mistake.

Judge's solution is ok.

Kentaro
New poster
Posts: 19
Joined: Thu Feb 05, 2004 4:41 am

### Sample Input?

Can someone who has gotten AC offer some sample input? It is really hard to verify cases by hand for me but despite every test I throw at it working, I still get WA.

Also, what should the output be if the input number is 0, or divisible by 2 or 5?

EDIT: I rethought the main loop of my program and the exit condition was too weak, so for some numbers the output number was too large. I replaced it with the correct condition and got AC. Still, I think the I/O would be a service to others working on this problem... does anyone want any?
Computer Science is no more about computers than Astronomy is about telescopes.
-- E. W. Dijkstra

mosaick2
New poster
Posts: 21
Joined: Wed Mar 08, 2006 4:05 am

### 10127. Ones - WA -

I think my logic is right.
But, I got WA.
Actually, I can't understand what's wrong in my code?
Help me If you know what's trouble.

Code: Select all

``````#include <iostream>
using namespace std;

int main()
{
int n;
do {
/* Input */
cin >> n;
/* Processing */
< Skipped for person who is solving this problem >

/* Output*/
cout << count << endl;
}while(!cin.eof());

return 0;
}
``````
Last edited by mosaick2 on Thu Apr 06, 2006 4:22 pm, edited 1 time in total.

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Contact:

Code: Select all

``````do{
Input
...
Output
}while(EOF);``````
Your code prints something unnecessary after reaching EOF.

mosaick2
New poster
Posts: 21
Joined: Wed Mar 08, 2006 4:05 am
mamun wrote:

Code: Select all

``````do{
Input
...
Output
}while(EOF);``````
Your code prints something unnecessary after reaching EOF.
Thanks, mamun.
I got AC. : )

ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

### 10127--need more sample I/O

Hi there plz give me some I/O of 10127
I like to solve problems.

abdullah<cse du>
New poster
Posts: 39
Joined: Mon Dec 04, 2006 2:18 pm
Contact:
ranacse05,

Try this input
Input

Code: Select all

``````1
11
109
5241
9999
8521
9789
23
17
999
``````
Output

Code: Select all

``````1
2
108
291
36
710
150
22
16
27
``````
ABDULLAH

SARKAR
New poster
Posts: 21
Joined: Tue May 22, 2007 4:18 pm

### presentation error

plzzzz help dunno y i m getting present error

Code: Select all

``````#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int a;
while(scanf("%i",&a)!=EOF)
{
int l=1;
int k=1,no=1;
while(1)
{
int l=k%a;
if(l==0)
{
printf("%i \n",no);
break;
}
k=l*10+1;
no++;
}
}
}
:cry: ``````

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Use

Code: Select all

``printf("%i\n",no);``
Since you are printing one extra space at the end of every line.
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

andmej
Experienced poster
Posts: 158
Joined: Sun Feb 04, 2007 7:45 pm
Location: Medellin, Colombia
Here are some extra test cases:

Input:
3
7
9
11
13
17
19
21
23
27
29
31
33
37
39
41
43
47
49
51
53
57
59
61
63
67
69
71
73
77
79
81
83
87
89
91
93
97
99
1001
1003
1007
1009
1011
1013
1017
1019
1021
1023
1027
1029
1031
1033
1037
1039
1041
1043
1047
1049
1051
1053
1057
1059
1061
1063
1067
1069
1071
1073
1077
1079
1081
1083
1087
1089
1091
1093
1097
1099
1101
And my accepted program spits this:
3
6
9
2
6
16
18
6
22
27
28
15
6
3
6
5
21
46
42
48
13
18
58
60
18
33
66
35
8
6
13
81
41
84
44
6
15
96
18
6
464
234
252
336
253
1008
1018
1020
30
78
294
103
1032
240
519
519
444
348
524
1050
162
150
96
212
1062
96
1068
144
84
537
246
506
342
1086
198
1090
273
1096
78
366
It must be more than enough, I hope.
Runtime errors in Pascal are reported as Wrong Answers by the online judge. Be careful.

Are you dreaming right now?
http://www.dreamviews.com

newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Contact:
i am also interested to know?

neo_thohin

dont use any language [that is not english]..
good luck

wasifhossain
New poster
Posts: 3
Joined: Tue Apr 28, 2009 7:26 pm

### Re: 10127 - Ones

"Bhagsash upopado" means nothing but "Remainder Theorem"