Ural 1014 The Product of Digits

这题想错了,就是把N分解了,如果素因子有大于等于10的就不行了,想复杂了

#include<iostream>
using namespace std;
int a[10]={0};
int main()
{
    
int n,i;
    cin
>>n;
    
if(n==0){cout<<10<<endl;return 0;}
    
else if(n==1){cout<<1<<endl; return 0;}
    
int p=n;
    
for(i=9; i>=2; )
    {
        
if(p%i==0){a[i]++; p/=i;}
        
else i--;
    }
    
if(p!=1){ cout<<-1<<endl; return 0; }
    
for(i=2; i<=9; i++)
    
for(int j=1; j<=a[i]; j++)
      cout
<<i;
    cout
<<endl;
    
    system(
"pause");
    
return 0;
}

posted on 2010-06-14 14:25 田兵 阅读(193) 评论(0)  编辑 收藏 引用 所属分类: URAL


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年6月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

导航

统计

常用链接

留言簿(2)

随笔分类(65)

随笔档案(65)

文章档案(2)

ACM

搜索

积分与排名

最新随笔

最新评论

阅读排行榜