Page 1 of 1

547 - DDF

Posted: Thu Aug 22, 2002 9:19 pm
by AlexandreN
Can you tell-me if this output is correct ?

INPUT

0 3000
2 3000
3000 2
100 200
200 100
1000 3000
2 1000
1000 2
15 15
14 16
16 14
2 15

OUTPUT

Input1: 0 3000
Output1: 924 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input2: 2 3000
Output2: 924 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input3: 3000 2
Output3: 924 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input4: 100 200
Output4: 162 66 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input5: 200 100
Output5: 162 66 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input6: 1000 3000
Output6: 1104 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input7: 2 1000
Output7: 924 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input8: 1000 2
Output8: 924 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input9: 15 15
Output9: 15
Input10: 14 16
Output10: 16 22 9 13 5 6 12 19 11 3 4 7 8 15
Input11: 16 14
Output11: 16 22 9 13 5 6 12 19 11 3 4 7 8 15
Input12: 2 15
Output12: 10 9 13 5 6 12 19 11 3 4 7 8 15

Posted: Thu Aug 22, 2002 9:42 pm
by Ivan Golubev
Yes, my accepted solution produces the same output as yours.

Posted: Thu Aug 22, 2002 9:51 pm
by AlexandreN
I found my mistake, got it accepted.

547 - DDF

Posted: Mon Apr 07, 2003 7:24 pm
by mrtamtam
i don't know where I get wrong..............
any good test case ?
I have search the previous post about 547..........
I have the same output as him...........
I don't know where is the problem.......
Please help..............

Posted: Fri Jun 20, 2003 6:57 pm
by angga888
Hi... :D

You can try these inputs:

Code: Select all

1 1
712 710
123 999
600 500
OUPUTS

Code: Select all

Input1: 1 1
Output1: 1
Input2: 712 710
Output2:  712 72 69 24 33 12 19 11 3 4 7 8 15
Input3: 123 999
Output3: 924 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Input4: 600 500
Output4: 518 66 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
Good Luck! :lol:

angga888 :lol:

547 TLE

Posted: Mon Jul 21, 2003 1:03 pm
by poulls
I don't know why it got TLE here is my code
Can antone help me ?

#include<iostream.h>
#include<math.h>

int add(int n)
{
if (n<10)
return n;
else
{
int t=0;
while(n)
{
t+=n%10;
n=n/10;
}
return t;
}
}

int main()
{
int m,n,mm,nn,i,j,nt=1;
int now,num,sum;
int a[1000],maxa[1000],max;
while(cin>>m>>n)
{
mm=m<n?m:n;
nn=m>n?m:n;
max=0;
for (i=mm;i<=nn;i++)
{
num=1;
now=i;
a[0]=0;
a[num]=now;
num++;

while(a[num-1]!=a[num-2])
{
sum=0;
for (j=1;j<sqrt(now);j++)
if (now%j==0)
{
sum+=add(j);
sum+=add(now/j);
}
if (j*j==now)
sum+=add(j);
a[num]=sum;
now=sum;
num++;
}
if (num-2>max)
{
max=num-2;
for (j=1;j<=max;j++)
maxa[j]=a[j];
}
}
cout<<"Input"<<nt<<": "<<m<<" "<<n<<endl;
cout<<"Output"<<nt<<":";
for (i=1;i<=max;i++)
{
cout<<" "<<maxa;
}
cout<<endl;
nt++;
}
return 0;
}

Posted: Sat Jul 26, 2003 10:10 am
by Joseph Kurniawan
Well, there's one cheat method. You should calculate the length of allof the possible input (1 - 3000) and then store their length in array :
int length[3010]={0,1,.....}

Good Luck!!

Posted: Sun Sep 28, 2003 12:51 pm
by anupam

Thank you Subeen Bhai. I should try to remove all the ambiguities from my src.
Thank you again.
Src is cut off as it gets ac.

Posted: Mon Sep 29, 2003 7:31 am
by Subeen
anupam: i found a bug in the code.

replace the line

Code: Select all

printf("Input%d: %d %d\nOutput%d: ",cas,a,b,cas++);
by

Code: Select all

printf("Input%d: %d %d\nOutput%d: ",cas++,a,b,cas);

Re: 547 - DDF

Posted: Fri Sep 03, 2010 4:54 pm
by Shafaet_du
Try to pass this samples:

15 15
Input1: 15 15
Output1: 15
1 1
Input2: 1 1
Output2: 1
0 1
Input3: 0 1
Output3: 0
1 3000
Input4: 1 3000
Output4: 924 168 102 36 46 18 30 27 22 9 13 5 6 12 19 11 3 4 7 8 15
1 1
Input5: 1 1
Output5: 1
0 0
Input6: 0 0
Output6: 0