【例题 7-1 UVA - 725】Division
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
枚举分母从0到99999.
得到分子,判断合法
【代码】
/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
*/
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> v1,v2,v3;
int main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
freopen("F:\\c++source\\rush_out.txt", "w", stdout);
#endif
ios::sync_with_stdio(0),cin.tie(0);
int kase = 0;
while (cin >>n && n){
if (kase>0) cout << endl;
kase++;
int cnt = 0;
for (int i = 1;i <= 99999;i++){
int x = i*n;
int y = i;
v1.clear(),v2.clear();
for (int i = 1;i <= 5;i++){
v1.push_back(x%10);
x/=10;
}
for (int i = 1;i <= 5;i++){
v2.push_back(y%10);
y/=10;
}
if (x>0) continue;
v3.clear();
for (int x:v1) v3.push_back(x);
for (int x:v2) v3.push_back(x);
sort(v3.begin(),v3.end());
int temp1 = unique(v3.begin(),v3.end()) - v3.begin();
if (temp1==10){
cnt++;
for (int i = 4;i >= 0;i--) cout << v1[i];
cout <<" / ";
for (int i = 4;i >= 0;i--) cout << v2[i];
cout <<" = "<<n<<endl;
}
}
if (cnt==0){
cout <<"There are no solutions for "<<n<<"."<<endl;
}
}
return 0;
}
【例题 7-1 UVA - 725】Division的更多相关文章
- 暴力枚举 UVA 725 Division
题目传送门 /* 暴力:对于每一个数都判断,是否数字全都使用过一遍 */ #include <cstdio> #include <iostream> #include < ...
- uva 725 Division(除法)暴力法!
uva 725 Division(除法) A - 暴力求解 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & ...
- UVA.725 Division (暴力)
UVA.725 Division (暴力) 题意分析 找出abcdefghij分别是0-9(不得有重复),使得式子abcde/fghij = n. 如果分别枚举每个数字,就会有10^10,肯定爆炸,由 ...
- uva 725 Division(暴力模拟)
Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...
- Uva 725 Division
0.不要傻傻的用递归去构造出一个五位数来,直接for循环最小到最大就好,可以稍微剪枝一丢丢,因为最小的数是01234 从1234开始,因为倍数n最小为2 而分子是一个最多五位数,所以分母应该小于五万. ...
- uva 725 division(水题)——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABVMAAAOHCAIAAAClwESxAAAgAElEQVR4nOydybGturJFcQEPfgQu4A
- UVA 725 – Division
Description Write a program that finds and displays all pairs of 5-digit numbers that between them ...
- uva 725 DIVISION (暴力枚举)
我的56MS #include <cstdio> #include <iostream> #include <string> #include <cstrin ...
- UVA 725 division【暴力枚举】
[题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...
- UVa 725 Division (枚举)
题意 : 输入正整数n,按从小到大的顺序输出所有形如abcde/fghij = n的表达式,其中a-j恰好为数字0-9的一个排列(可以有前导0),2≤n≤79. 分析 : 最暴力的方法莫过于采用数组存 ...
随机推荐
- python 协程学习
协程 协程,又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程. 协程拥有自己的寄存器上下文和栈.协程调度切换时,将寄存器上下文和栈保存到其他地方,在切回来 ...
- Vue 项目搭建 与 git 连接
整理一下::::: git 方面: -----------注册------登录--------就不用写了 这里使用的是码云: 1. 进入个人中心添加项目. 2.添加完项目添加SSH公钥.(在设置里面) ...
- sed的一些tricks
1.sed -f xx.sed input_file 可以将一系列操作放在一个xx.sed脚本里执行 ``` #!/bin/sed -f ``` 2.在匹配字符串后面或行尾添加内容 在text后面添加 ...
- C++ 不输入回车就不结束输入的实现方法
方法一 char mystr[128]; mystr[0] = '\0'; char c = getchar(); int i=0; while(c!='\n') { mystr[i] = c; c ...
- jquery的ajax总结
jquery的ajax总结 一.总结 一句话总结:ajax函数中层级关系如下: 最底层的封装方式: $.ajax(); 第二层: .load(),$.get(), $.post() 最高层: $.ge ...
- 酉矩阵(unitary matrix)
复方阵 U 称为酉矩阵,如果满足: U∗U=UU∗=I 换句话说,矩阵 U 的共轭转置 U∗ 就是 U 的逆矩阵. U∗=U−1 1. unitary matrix 保持内积不变 ⟨Ux,Uy⟩=⟨x ...
- POJ 1988 带偏移量的并查集
题意: 思路: 数据范围很大 貌似只能用并查集了-- //By SiriusRen #include <cstdio> using namespace std; int p,f[33333 ...
- linux的dhcp4.1.1服务部署
Centos6.5的dhcp4.1.1服务部署 实施步骤: 1:设置DHCP服务器静态IP和主机名 [root@sw ~]# vim /etc/sysconfig/network-scripts/i ...
- C# 将引用的DLL文件放到指定的目录下
原文:C# 将引用的DLL文件放到指定的目录下 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sweety820/article/details/2 ...
- 重构insert update 比较两个datatbale
#region 下载时重构insert(数据带null处理) public void DownDataInsert(DataTable _dt, string TableName,DBHelper d ...