ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1014. Product of Digits

My code__I put it to help and to learn not for copy paste!
Posted by Mister Bean 10 Sep 2008 06:37
import java.util.*;
import java.io.*;
import java.lang.String;

public class P1014{
public static void main(String[] args){
Scanner in=new  Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
long m=0;
int i=0;
String num;
try{
int n=in.nextInt();
 if(n==1)
      out.println("1");
 else
 if(n<10)
 out.println("1"+n);
  else
  {
      for(i=9;i>1;i--)
   {
   if(n%i==0)
  { n=n/i;
    m=m*10+i;
    i++;
 }}
 if(n!=1)
        out.print("-1");
 else{
 String s=Long.toString(m);
  for(i=s.length()-1;i>=0;i--)
  out.print(s.charAt(i));
  }}
}catch(Exception e){
  out.println(e);
   }
   out.flush();
}}
For C++ code and other queqtions write imran_yusubov@yahoo.com

Edited by author 10.09.2008 06:38
Re: My code__I put it to help and to learn not for copy paste!
Posted by nguyenductam 28 Mar 2010 18:31
I think Mister Bean,too . Timus Online Judge is playground for intelligence of student information technology. Learn algorithm to solve is main. thank you Mister Bean, you help me very much.

Edited by author 28.03.2010 18:31