UVA 725 UVA 10976 简单枚举
#include<cstdio>
#include<cstring>
int num[];
bool check(int a,int b) {
memset(num,,sizeof num);
if(b>) return false;
if(a<) num[]++;
if(b<) num[]++;
while(a) {
num[a%]++;
a/=;
}
while(b) {
num[b%]++;
b/=;
}
for(int i=;i<;i++) {
if(num[i]>) return false;
}
return true;
}
int main() {
int n,cnt=;
while(~scanf("%d",&n),n!=) {
if(cnt>) printf("\n");cnt++;
int flag=;
for(int i=;i<=/n;i++) {
if(check(i,i*n)) {
flag=;
printf("%05d / %05d = %d\n",i*n,i,n);
}
}
if(flag==) printf("There are no solutions for %d.\n",n);
}
return ;
}
#include<cstdio>
int res[][];
int main() {
int k;
while(~scanf("%d",&k)) {
int x,y;
int cnt=;
for(y=k+;y<=*k;y++) {
if((k*y)%(y-k)==) {
x=(k*y)/(y-k);
res[cnt][]=x;res[cnt++][]=y;
}
}
printf("%d\n",cnt);
for(int i=;i<cnt;i++) {
printf("1/%d = 1/%d + 1/%d\n",k,res[i][],res[i][]);
}
}
return ;
}
UVA 725 UVA 10976 简单枚举的更多相关文章
- UVA 725 division【暴力枚举】
[题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...
- 暴力枚举 UVA 725 Division
题目传送门 /* 暴力:对于每一个数都判断,是否数字全都使用过一遍 */ #include <cstdio> #include <iostream> #include < ...
- UVA - 10167 - Birthday Cake (简单枚举)
思路:简单枚举 AC代码: #include <cstdio> #include <cstring> #include <iostream> #include &l ...
- uva 725 Division(暴力模拟)
Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...
- 除法(Division ,UVA 725)-ACM集训
参考:http://www.cnblogs.com/xiaobaibuhei/p/3301110.html 算法学到很弱,连这么简单个问题都难到我了.但我偏不信这个邪,终于做出来了.不过,是参照别人的 ...
- uva 725 Division(除法)暴力法!
uva 725 Division(除法) A - 暴力求解 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & ...
- UVA.12716 GCD XOR (暴力枚举 数论GCD)
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...
- UVA.725 Division (暴力)
UVA.725 Division (暴力) 题意分析 找出abcdefghij分别是0-9(不得有重复),使得式子abcde/fghij = n. 如果分别枚举每个数字,就会有10^10,肯定爆炸,由 ...
- UVA 1508 - Equipment 状态压缩 枚举子集 dfs
UVA 1508 - Equipment 状态压缩 枚举子集 dfs ACM 题目地址:option=com_onlinejudge&Itemid=8&category=457& ...
随机推荐
- 穿透Session 0 隔离(一)
服务(Service)对于大家来说一定不会陌生,它是Windows 操作系统重要的组成部分.我们可以把服务想像成一种特殊的应用程序,它随系统的“开启-关闭”而“开始-停止”其工作内容,在这期间无需任何 ...
- pug.compile() will compile the Pug source code into a JavaScript function that takes a data object (called “locals”) as an argument.
Getting Started – Pug https://pugjs.org/api/getting-started.html GitHub - Tencent/wepy: 小程序组件化开发框架 h ...
- centos7 Docker Compose 的安装
[root@localhost ~]# curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose ...
- Java HashMap工作原理及实现(转载)
https://yikun.github.io/2015/04/01/Java-HashMap工作原理及实现/
- netstat命令——网络,进程,内存
netstat网络.进程.内存 转自:https://www.cnblogs.com/xieshengsen/p/6618993.html https://zhidao.baidu.com/quest ...
- django--博客--forms组件-用户注册
---------------------------------------------前端页面简易代码----------------------------------------------- ...
- What is tail-recursion
Consider a simple function that adds the first N integers. (e.g. sum(5) = 1 + 2 + 3 + 4 + 5 = 15). H ...
- Spring-Hello World实例
Spring Hello World实例 创建Java项目 添加Jar包 创建源文件 现在在Spring项目下创建实际的源文件.首先,要创建一个名为com.tuorialsponit的包,然后在该co ...
- sql server dba之路
转自:https://blog.csdn.net/dba_huangzj/article/details/7841441 在专职DBA工作一年过一个月以后,开通了CSDN的博客专栏,在第一篇文章中,我 ...
- GET和POST请求区别
关于http协议GET和POST方法的区别我们可以从各处得到比较一致的答案,今天我们来填一个面试中可能碰到的一个坑. 当面试官问你“你觉得GET和POST有什么区别"时,我们可能会想到以下几 ...