博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
暴力枚举 UVA 725 Division
阅读量:6867 次
发布时间:2019-06-26

本文共 1142 字,大约阅读时间需要 3 分钟。

 

1 /* 2     暴力:对于每一个数都判断,是否数字全都使用过一遍 3 */ 4 #include 
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 using namespace std;14 15 const int MAXN = 1e4 + 10;16 const int INF = 0x3f3f3f3f;17 int vis[10];18 19 bool ok(int x, int y)20 {21 memset (vis, 0, sizeof (vis));22 for (int i=1; i<=5; ++i)23 {24 vis[x%10]++; vis[y%10]++;25 if (vis[x%10] > 1 || vis[y%10] > 1) return false;26 x /= 10; y /= 10;27 }28 29 return true;30 }31 32 int main(void) //UVA 725 Division33 {34 //freopen ("UVA_725.in", "r", stdin);35 36 int n, cnt = 0;37 while (scanf ("%d", &n) == 1)38 {39 if (n == 0) break;40 if (cnt++) puts ("");41 42 int one = 0;43 for (int i=1234; i<=100000/n; ++i)44 {45 if (i * n > 98765) break;46 if (ok (i, i*n) == true)47 {48 printf ("%05d / %05d = %d\n", n*i, i, n); one++;49 }50 }51 52 if (!one) printf ("There are no solutions for %d.\n", n);53 }54 55 return 0;56 }57 58 59 /*60 There are no solutions for 61.61 */

 

转载于:https://www.cnblogs.com/Running-Time/p/4463227.html

你可能感兴趣的文章
Springboot应用缓存实践之:Ehcache加持
查看>>
CSS+DIV之流式布局
查看>>
客车网上售票系统(Java源码+sql脚本)
查看>>
创新扶贫机制 助推产业发展——2019消费扶贫与乡村振兴(深圳)大会即将召开...
查看>>
linux之入门---U盘安装centos7.3
查看>>
运维Linux技巧
查看>>
熊掌号是什么及对小网站真的有保护作用吗?
查看>>
java虚拟机内存监控工具
查看>>
chmod命令、chown命令、umask命令、chattr命令、lsattr命令
查看>>
APP网站安全漏洞检测服务的详细介绍
查看>>
Knative Eventing 中如何实现 Registry 事件注册机制
查看>>
今天的学习
查看>>
Makefile有三个非常有用的变量。分别是$@,$^,$
查看>>
网络大厂和以色列研究团运用ML打造洪水预测模型
查看>>
Dart | 浅析dart中库的导入与拆分
查看>>
FFMpeg编程1 环境搭建
查看>>
SpringBoot | 第十八章:web应用开发之WebJars使用
查看>>
Web开发:我希望得到的编程学习路线图
查看>>
Hadoop Outline Part 3 (I/O - Avro)
查看>>
Ubuntu16.04下查看软件版本及安装位置
查看>>