10633  Rare Easy Problem
Moderator: Board moderators
Here is a proof that finds the answers mathematically,
N = original number
M = N with last digit chopped off
B = the chopped off digit
So that,
N = 10M + B where (0<=B<=9)
NM = (10M+B)M = 9M+B
We can calculate
(NM)%9 = (9M+B)%9 = (9M)%9 + (B)%9 = B%9
If B%9==0, then B can be either 0 or 9,
B=0 implies NM = 9M, so M = (NM)/9, and
N = M + (NM) = (NM)/9 + (NM) = (NM)/9*10 (< answer 1)
B=9 implies NM = 9M+9, N = (NM)/9  1, and
N = M + (NM) = (NM)/9  1 + (NM) = (NM)/9*10  1 (< answer 2)
If B%9!=0, since 0<=B<=9, it must be that B<9, so B/9 = 0.
So NM = 9M+B and (NM)/9 = M + B/9 = M, hence
N = M + (NM) = (NM)/9 + (NM) = (NM)/9*10 (< answer 1)
N = original number
M = N with last digit chopped off
B = the chopped off digit
So that,
N = 10M + B where (0<=B<=9)
NM = (10M+B)M = 9M+B
We can calculate
(NM)%9 = (9M+B)%9 = (9M)%9 + (B)%9 = B%9
If B%9==0, then B can be either 0 or 9,
B=0 implies NM = 9M, so M = (NM)/9, and
N = M + (NM) = (NM)/9 + (NM) = (NM)/9*10 (< answer 1)
B=9 implies NM = 9M+9, N = (NM)/9  1, and
N = M + (NM) = (NM)/9  1 + (NM) = (NM)/9*10  1 (< answer 2)
If B%9!=0, since 0<=B<=9, it must be that B<9, so B/9 = 0.
So NM = 9M+B and (NM)/9 = M + B/9 = M, hence
N = M + (NM) = (NM)/9 + (NM) = (NM)/9*10 (< answer 1)
10633 help!
hi,i used range from 10 to +10 ,but got TLE,i am so confused,why??
[cpp]
AC now
[/cpp]
[cpp]
AC now
[/cpp]
Last edited by oulongbin on Mon Oct 11, 2004 1:32 pm, edited 1 time in total.

 Guru
 Posts: 724
 Joined: Wed Dec 19, 2001 2:00 am
 Location: Germany
 Ghust_omega
 Experienced poster
 Posts: 115
 Joined: Tue Apr 06, 2004 7:04 pm
 Location: Venezuela
10633  Rare easy problem WA
Hi !! to all , I thinks this problem is easy just I can not find the error,
I use long double in C for read the number %Lf as the same for print
just is %.0Lf is this ok??? , in my solution only I have to ways to
say is this with multiple answers or not
this is some I/O please help me
in:
out:
Thanks in advance
Keep posting !!
I use long double in C for read the number %Lf as the same for print
just is %.0Lf is this ok??? , in my solution only I have to ways to
say is this with multiple answers or not
Code: Select all
if (Nm%9==0)
have two answers
else
only one
in:
Code: Select all
18
19
20
27
36
345
345
234
23
10000
1000000000000000000
10
80
90
6756756756
3423452353452
53252353225345243
465756865455532
5475665432
56765432478
900
7888
5677
34777
2390
45690
56790
Code: Select all
19 20
21
22
29 30
39 40
383
383
259 260
26
11111
1111111111111111111
11
89
99 100
7507507507
3803835948279 3803835948280
59169281361494714
517507628283924
6084072702
63072702753
999 1000
8764
6308
38641
2656
50767
63099 63100
Keep posting !!
 Ghust_omega
 Experienced poster
 Posts: 115
 Joined: Tue Apr 06, 2004 7:04 pm
 Location: Venezuela

 Experienced poster
 Posts: 131
 Joined: Sat Jul 17, 2004 4:09 am
 Location: Lima, Per
10633 Rare Easy Problem
I got WA. Please what's wrong in my code??
Code: Select all
Cut after AC :D
Last edited by Antonio Ocampo on Sun Dec 19, 2004 8:18 pm, edited 1 time in total.

 Experienced poster
 Posts: 131
 Joined: Sat Jul 17, 2004 4:09 am
 Location: Lima, Per

 Experienced poster
 Posts: 131
 Joined: Sat Jul 17, 2004 4:09 am
 Location: Lima, Per
unsigned long long !
Yes, use unsigned long long.
This is the most natural choice and
the first builtin C++ type I chose to try for this problem.
It works for even bigger numbers in input
( bigger than 10^18 ).
This is the most natural choice and
the first builtin C++ type I chose to try for this problem.
It works for even bigger numbers in input
( bigger than 10^18 ).
10633 (Rare Easy problem)
Hi, here is my code , i don't know why i am given TLE. Pls help me.
Code: Select all
#include<stdio.h>
int main()
{
unsigned long long int a,b,c,d,n,f,count;
while(scanf("%llu",&n) && n)
{
a = n;
b = n/10;
count = 0;
while(1)
{
c = a+b;
d = c  (c/10);
if(d == n)
{
if(!count)
{
printf("%llu",c);
count ++;
}
else
printf(" %llu",c);
}
else if(d>n) break;
b++;
}
printf("\n");
}
return 0;
}