547 - DDF
Moderator: Board moderators
-
- New poster
- Posts: 27
- Joined: Sun Jul 07, 2002 6:46 pm
- Location: Campina Grande - Brazil
- Contact:
547 - DDF
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
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
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
-
- New poster
- Posts: 27
- Joined: Sun Jul 07, 2002 6:46 pm
- Location: Campina Grande - Brazil
- Contact:
547 - DDF
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..............
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..............
Hi...
You can try these inputs:
OUPUTS
Good Luck!
angga888

You can try these inputs:
Code: Select all
1 1
712 710
123 999
600 500
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

angga888

547 TLE
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;
}
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;
}
-
- Experienced poster
- Posts: 136
- Joined: Tue Apr 01, 2003 6:59 am
- Location: Jakarta, Indonesia
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.
Last edited by anupam on Mon Sep 29, 2003 7:46 am, edited 2 times in total.
"Everything should be made simple, but not always simpler"
anupam: i found a bug in the code.
replace the line
by
replace the line
Code: Select all
printf("Input%d: %d %d\nOutput%d: ",cas,a,b,cas++);
Code: Select all
printf("Input%d: %d %d\nOutput%d: ",cas++,a,b,cas);
-
- Experienced poster
- Posts: 147
- Joined: Mon Jun 07, 2010 11:43 am
- Location: University Of Dhaka,Bangladesh
- Contact:
Re: 547 - DDF
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
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
UVa stats: http://felix-halim.net/uva/hunting.php?id=63448
My blog on programming: http://www.shafaetsplanet.com/planetcoding/
My blog on programming: http://www.shafaetsplanet.com/planetcoding/