UVa725

 1 #include <iostream>
 2 #include <cstring>
 3 #include <string>
 4 #include <map>
 5 #include <set>
 6 #include <algorithm>
 7 #include <fstream>
 8 #include <cstdio>
 9 #include <cmath>
10 #include <stack>
11 #include <queue>
12 using namespace std;
13 const double Pi=3.14159265358979323846;
14 typedef long long ll;
15 const int MAXN=5000+5;
16 const int dx[5]={0,0,0,1,-1};
17 const int dy[5]={1,-1,0,0,0};
18 const int INF = 0x3f3f3f3f;
19 const int NINF = 0xc0c0c0c0;
20 const ll mod=1e9+7;
21 int a[10];
22 int main()
23 {
24     int n;int cnt=0;
25     while(cin>>n&&n!=0)
26     {
27         if(cnt++ != 0) cout<<endl; 
28         int s=1;
29         for(int i=12345;i<=98765;i++)
30         {
31             memset(a,0,sizeof(a));
32             if(i%n==0)
33             {
34                 //6cout <<i<<endl;
35                 int m=i/n;
36                 if(m>1233)    
37                 {
38                     int t=i;if(m<10000) a[0]=1;
39                     while(t)
40                     {
41                         a[t%10]=1;t/=10;
42                     }
43                     while(m)
44                     {
45                         a[m%10]=1;m/=10;
46                     }
47                 }
48                 int flag=1; 
49                 for(int j=0;j<=9;j++)
50                 {
51                     if(a[j]==0)
52                     {
53                         flag=0;
54                         break;
55                     }
56                 }
57                 /*for(int j=0;j<=9;j++)
58                 {
59                     cout <<a[j]<<" ";
60                  } 
61                  cout <<endl;*/
62                 if(flag) 
63                 {
64                     if(i/n<10000) printf("%d / 0%d = %d\n",i,i/n,n);
65                     else printf("%d / %d = %d\n",i,i/n,n);
66                     s=0;
67                 }
68             }
69             
70         } 
71         if(s) printf("There are no solutions for %d.\n",n);
72     }
73     return 0;
74  } 

要注意输出,最后一组数据不能再输出空行

转载于:https://www.cnblogs.com/Msmw/p/10636936.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值