码迷,mamicode.com
首页 > 其他好文 > 详细

{暴力}

时间:2017-07-10 00:40:40      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:color   pen   turn   isp   tar   get   target   src   puts   

补一些基础简单题purple7

UVA - 725

技术分享
 1 #include <cstdio>
 2 #include <bits/stdc++.h>
 3 using namespace std;
 4 
 5 bool check(int x,int y)
 6 {
 7     int a[10];
 8     memset(a,0,sizeof(a));
 9     if(x<10000||y<10000) a[0]=1;  //
10     if(x<10000&&y<10000) return false;   //
11     while(x)
12     {
13         int temp=x%10;
14         if(a[temp]) return false;
15         a[temp]=1;
16         x/=10;
17     }
18     while(y)
19     {
20         int temp=y%10;
21         if(a[temp]) return false;
22         a[temp]=1;
23         y/=10;
24     }
25 
26     return true;
27 }
28 
29 int main()
30 {
31     int n;
32     int flag=0;
33     while(scanf("%d",&n)&&n)
34     {
35         if(flag)
36         {
37             puts("");
38         }
39         else flag=1;
40         int ok=0;
41         for(int i=1234;;i++)
42         {
43             int y=i*n;
44             if(y>98765) break;
45 
46             if(check(i,y)) ok=1,printf("%d / %05d = %d\n",y,i,n);
47         }
48         if(!ok) printf("There are no solutions for %d.\n",n);
49     }
50 }
View Code

 

{暴力}

标签:color   pen   turn   isp   tar   get   target   src   puts   

原文地址:http://www.cnblogs.com/yijiull/p/7143698.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!