640 - Self Numbers

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Tue May 08, 2007 3:10 pm

Look the intervals of the Self Numbers. You may notice that there is a pattern ..

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am

Post by hamedv » Wed May 23, 2007 6:15 pm

rio wrote:Look the intervals of the Self Numbers. You may notice that there is a pattern ..
thanks :D

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Post by sohel » Thu May 24, 2007 10:20 am

A harder version of this problem-
11032 :- Function Overloading :: http://acm.uva.es/p/v110/11032.html

Mohamed Abd El-Monem
New poster
Posts: 15
Joined: Mon Mar 31, 2008 1:20 am
Location: Egypt
Contact:

Re: 640 - Self Numbers

Post by Mohamed Abd El-Monem » Thu Jun 12, 2008 5:25 pm

this is the last Self numbers my code generated

999943
999945
999956
999967
999978
999989

what is the missing one here :roll:
i get WA

this is my code ,, plz any help.. thanx in advace

Code: Select all

Deleted After accepted
Last edited by Mohamed Abd El-Monem on Thu Jun 12, 2008 10:03 pm, edited 1 time in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Re: 640 - Self Numbers

Post by Jan » Thu Jun 12, 2008 9:46 pm

What about 1000000?
Ami ekhono shopno dekhi...
HomePage

Mohamed Abd El-Monem
New poster
Posts: 15
Joined: Mon Mar 31, 2008 1:20 am
Location: Egypt
Contact:

Re: 640 - Self Numbers

Post by Mohamed Abd El-Monem » Thu Jun 12, 2008 10:01 pm

thanks jan , really what about 1000000 :lol:
,I have got accepted

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 640 - Self Numbers

Post by Obaida » Sun Jul 27, 2008 2:41 pm

Some one please help me. I got CE several times!!!

Code: Select all

mistake found.  
try_try_try_try_&&&_try@try.com
This may be the address of success.

Rocklets
New poster
Posts: 2
Joined: Wed Nov 12, 2008 10:07 pm

Re: 640 - Self Numbers

Post by Rocklets » Wed Nov 12, 2008 10:10 pm

hi im new in this forum :D i have AC from all ur posts :D, my solution is very simple :D

Code: Select all

AC code removed by moderator!
thx :D

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 640 - Self Numbers

Post by Obaida » Thu Nov 13, 2008 11:05 am

To Rocklets,
You shouldn't post an accepted solution in the board. Please remove your code.
try_try_try_try_&&&_try@try.com
This may be the address of success.

User avatar
vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

Re: 640 - Self Numbers

Post by vahid sanei » Mon May 11, 2009 9:07 pm

Code: Select all

640`s pdf is not same with problem 
Last edited by vahid sanei on Wed May 13, 2009 9:39 pm, edited 1 time in total.
Impossible says I`m possible

User avatar
vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

Re: 640 - Self Numbers

Post by vahid sanei » Wed May 13, 2009 9:38 pm

I downloaded its pdf , and in pdf problem says
"Write a program to output all positive self-numbers less than or equal 10000 in increasing order, one per line." :D
Impossible says I`m possible

poline_trinity
New poster
Posts: 1
Joined: Tue Jan 25, 2011 8:10 am

Re: 640 - Self Numbers

Post by poline_trinity » Tue Jan 25, 2011 8:38 am

Why I am getting runtime error
Here is my code:

Code: Select all

#include<stdio.h>

#define max 1000001
char a[max];
long digit(long n)
{
    int sum=0;
    while(n!=0)
    {
      sum+=(n%10);
      n=n/10;
    }
    return sum;
    
}
int main()
{
    long i,n,k,d;
    
    for(i=1;i<=max;i++)a[i]=1;
    for(i=1;i<=max;)
    {
     k=i;
     while(1)
     {
     d=k+digit(k);
     if((d>=max)||!a[d])  
     break;
     a[d]=0;
     k=d;
     }
     for(i++;!a[i];i++) ; 
     }
     for(i=1;i<max;i++)
     if(a[i]){
     printf("%ld\n",i);            
   }
    
    return 0;
}

ujjal.ruet
New poster
Posts: 15
Joined: Thu Sep 02, 2010 3:10 pm
Location: Dhaka,Bangladesh
Contact:

Re: 640 - Self Numbers

Post by ujjal.ruet » Tue Jan 25, 2011 9:52 am

I solved it. Its a easy problem. I have used an array a.

for i=0 tp i=1000000
a=0

for i=0 tp i=1000000
i+=sumofdigit(i)
a=1


then i just print indexes whose value is 0.

thets it.

alimbubt
New poster
Posts: 39
Joined: Tue Aug 07, 2012 10:40 pm
Location: BUBT,Dhaka, Bangladesh
Contact:

Re: 640 - Self Numbers

Post by alimbubt » Mon Feb 25, 2013 10:35 pm

I have used the following approach to solve this problem.......

Code: Select all

1) Use an array and make sure the global declaration of the array so that the indexed value preset as zero.
2) Now start a loop from index i=1 to i=1000000.
3) If sum=i+digitsum of i, then set array[sum]=1.
4) Now just print the value of array indexed with zero.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe...(BUBT ILLUSION)
http://uhunt.felix-halim.net/id/155497
http://onlyprogramming.wordpress.com/

AbyssalGreed
New poster
Posts: 9
Joined: Mon Aug 25, 2014 5:25 am

Re: 640 - Self Numbers

Post by AbyssalGreed » Mon Sep 01, 2014 12:24 pm

hi!
i need help with 640 - self number, here is my code:
and also can someone pls send me an output for larger number; :)

Code: Select all

import java.io.*;
import java.util.*;
import java.math.*;
import java.text.*;
import java.lang.*;

class Main
{
   public static void main(String args[])
   {
      setNumbers();
   }
   public static void setNumbers()
   { 

    int[] numbers=new int[1000000]; 
     for(int i=1;i< 1000000;i++){
       int temp = i+i%10+(i/10)%10+(i/100)%10+i/1000000; 
               if(temp< 1000000) 
                   numbers[temp]=1;  
            } 
             for(int i=1;i< 1000000;i++){
                     if(numbers[i]==0)  
                          System.out.println(i); 
             }  
     }
}
thanks in advace 8)

Post Reply

Return to “Volume 6 (600-699)”