Números Smith

download Números Smith

If you can't read please download the document

description

Solución

Transcript of Números Smith

Nmeros de Smith - Problema UVA 10042Bsicamente, este problema busca encontrar nmeros en los que la suma de sus dgitos sea igual a la suma de sus factores primos.El enunciado est en el enlace http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=983import java.io.*; class Main { static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static void main(String args[]) throws Exception { Main myWork = new Main(); // create a dinamic instance myWork.Begin(); // the true entry point } public int sumaDivisores(int n) { double raiz = Math.sqrt(n); int tmp = n; int respuesta=0; while(n%2==0) { respuesta+=2; n>>=1; } for(int i=3; i0) { respuesta+=(n%10); n = n/10; } return respuesta; } public boolean esPrimo(long n) { double raiz = Math.sqrt(n); if(n==2) return true; if(n%2==0) return false; for(int i=3; i