Page 3 of 4

Posted: Tue May 08, 2007 3:10 pm
by rio
Look the intervals of the Self Numbers. You may notice that there is a pattern ..

Posted: Wed May 23, 2007 6:15 pm
by hamedv
rio wrote:Look the intervals of the Self Numbers. You may notice that there is a pattern ..
thanks :D

Posted: Thu May 24, 2007 10:20 am
by sohel
A harder version of this problem-
11032 :- Function Overloading :: http://acm.uva.es/p/v110/11032.html

Re: 640 - Self Numbers

Posted: Thu Jun 12, 2008 5:25 pm
by Mohamed Abd El-Monem
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

Re: 640 - Self Numbers

Posted: Thu Jun 12, 2008 9:46 pm
by Jan
What about 1000000?

Re: 640 - Self Numbers

Posted: Thu Jun 12, 2008 10:01 pm
by Mohamed Abd El-Monem
thanks jan , really what about 1000000 :lol:
,I have got accepted

Re: 640 - Self Numbers

Posted: Sun Jul 27, 2008 2:41 pm
by Obaida
Some one please help me. I got CE several times!!!

Code: Select all

mistake found.  

Re: 640 - Self Numbers

Posted: Wed Nov 12, 2008 10:10 pm
by Rocklets
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

Re: 640 - Self Numbers

Posted: Thu Nov 13, 2008 11:05 am
by Obaida
To Rocklets,
You shouldn't post an accepted solution in the board. Please remove your code.

Re: 640 - Self Numbers

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

Code: Select all

640`s pdf is not same with problem 

Re: 640 - Self Numbers

Posted: Wed May 13, 2009 9:38 pm
by vahid sanei
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

Re: 640 - Self Numbers

Posted: Tue Jan 25, 2011 8:38 am
by poline_trinity
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;
}

Re: 640 - Self Numbers

Posted: Tue Jan 25, 2011 9:52 am
by ujjal.ruet
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.

Re: 640 - Self Numbers

Posted: Mon Feb 25, 2013 10:35 pm
by alimbubt
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.

Re: 640 - Self Numbers

Posted: Mon Sep 01, 2014 12:24 pm
by AbyssalGreed
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)