UVa 725 Division
来源:互联网 发布:海知智能上市了吗 编辑:程序博客网 时间:2024/05/16 04:58
Algorithm
枚举
Hint
文件末尾不能有空行
Code
#include <cstring>#include <iostream>using namespace std;int n;bool flag;bool b[10];void solve(){ flag = false; for (int f = 0; f < 10; f++) for (int g = 0; g < 10; g++) for (int h = 0; h < 10; h++) for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) { memset(b, 0, sizeof(b)); b[f] = true; if (b[g]) continue; b[g] = true; if (b[h]) continue; b[h] = true; if (b[i]) continue; b[i] = true; if (b[j]) continue; b[j] = true; long long abcde = n * (f * 10000 + g * 1000 + h * 100 + i * 10 + j); if (abcde > 99999) continue; int a = abcde / 10000; abcde %= 10000; if (b[a]) continue; b[a] = true; int bb = abcde / 1000; abcde %= 1000; if (b[bb]) continue; b[bb] = true; int c = abcde / 100; abcde %= 100; if (b[c]) continue; b[c] = true; int d = abcde / 10; abcde %= 10; if (b[d]) continue; b[d] = true; int e = abcde; if (b[e]) continue; cout << a << bb << c << d << e << " / " << f << g << h << i << j << " = " << n << endl; flag = true; } if (!flag) cout << "There are no solutions for " << n << "." << endl;}int main(){ cin >> n; if (n == 0) return 0; solve(); for (;;) { cin >> n; if (n == 0) break; cout << endl; solve(); }}
0 0
- UVA 725 - Division
- UVA 725 - Division
- UVa 725 - Division
- UVA - 725 Division
- UVa 725 - Division
- UVa 725 Division
- UVa 725 - Division
- Uva 725 Division
- UVA-725除法-Division
- UVA - 725 Division
- uva 725 - Division
- Uva - 725 - Division
- UVA - 725 Division
- uva 725 Division
- 除法(Division, UVa 725)
- UVA 725 Division
- UVA 725 - Division
- UVa 725----Division(枚举)
- 守护进程知识及示例
- to many values to unpack
- LeetCode 113 Path Sum II
- LintCode:报数
- [Ahoi2013]作业 解题报告
- UVa 725 Division
- 六款值得推荐的android(安卓)开源框架简介
- 虚拟机安装后找不到操作系统
- 关于最短路径中的Dijkstra和Bell-man算法的区别
- 条件判断
- TCP三次握手
- HDU2047
- 为顺丰总裁点赞:管理就是向下负责
- 深入浅出之JVM GC篇