除法

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=84562#problem/A

题意:

输入正整数n按从小到大的顺序输出所有形如abcde/fghij=n的表达式,其中

a~j恰好为0~9的一个排列(可以有前导0),2<=n<=79。

Sample Input

61
62
0

Sample Output

There are no solutions for 61.

79546 / 01283 = 62
94736 / 01528 = 62

分析:

由fghij可以算出abcde,所有我们只需要枚举fghij,然后判断abcdefghij这些数字是否都不相等即可。

注意输出的格式(空格)。

 #include<iostream>
#include<cstdio>
using namespace std;
int b[];
int per(int x,int y)
{int i;
if(y>) return ;
for(i=;i<;i++)
b[i]=;
if(x<) b[]=;
while(x)
{
b[x%]=;
x=x/;
}
while(y)
{
b[y%]=;
y=y/;
}
int sum=;
for( i=;i<;i++)
sum=sum+b[i];
return (sum==);
}
int main()
{
int n,c=,i,count;
scanf("%d",&n);
while(n)
{
if(c++) cout<<endl;
count=;
for(i=;i<;i++)
{
if(per(i,i*n))
{
printf("%05d / %05d = %d\n",i*n,i,n);
count++;
}
}
if(count==)
printf("There are no solutions for %d.\n",n);
scanf("%d",&n);
} return ;
}

除法 Division的更多相关文章

  1. 暴力求解——除法 Division,UVa 725

    Description Write a program that finds and displays all pairs of 5-digit numbers that between them u ...

  2. java入门学习(九) 算术运算符

    请大家关注我的博客www.taomaipin.com 运算符在java基础中也占有着举足轻重的位置,我们当然要学会它.java 其实和其他计算机语言一样,基本的算术运算符基本一样,让我们看看 有哪些算 ...

  3. JAVA_SE基础——11.Java中的运算符

    在程序设计中,运算符应用得十分广泛,通过运算符可以将两个变量进行任意运算.数学中的"+"."-"."*"."/"运算符同 ...

  4. Java基础__Java中常用数学类Math那些事

     测试 package Cynical_Gary; public class Cynical_Text { public static void main(String[] args){ System ...

  5. 01_02_py

    1基础知识 1.自然语言 (natural language) 是人们交流所使用的语言,例如英语.西班牙语和法语.它们不是人为设计出来的(尽管有人试图这样做):而是自然演变而来. 2.形式语言 (fo ...

  6. [LeetCode] Evaluate Division 求除法表达式的值

    Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...

  7. uva 725 Division(除法)暴力法!

    uva 725  Division(除法) A - 暴力求解 Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & ...

  8. [Swift]LeetCode399. 除法求值 | Evaluate Division

    Equations are given in the format A / B = k, where A and B are variables represented as strings, and ...

  9. [Swift]LeetCode553. 最优除法 | Optimal Division

    Given a list of positive integers, the adjacent integers will perform the float division. For exampl ...

随机推荐

  1. Python3 基本数据类型注意事项

    Python3 基本数据类型 教程转自菜鸟教程:http://www.runoob.com/python3/python3-data-type.html Python中的变量不需要声明.每个变量在使用 ...

  2. linux驱动程序设计的硬件基础,王明学learn

    linux驱动程序设计的硬件基础(一) 本章讲总结学习linux设备程序设计的硬件基础. 一.处理器 1.1通用处理器 通用处理器(GPP)并不针对特定的应用领域进行体系结构和指令集的优化,它们具有一 ...

  3. 链接器工具错误 LNK2026 XXX模块对于 SAFESEH 映像是不安全的

    解决方法: 1.打开该项目的"属性页"对话框. 2.单击"链接器"文件夹. 3.单击"命令行"属性页. 4.将 /SAFESEH:NO 键入 ...

  4. codeforces Round#380 div2

    1.字符串替换ogo+go…换成*** 思路:找ogo记录g位置,做初步替换和标记,非目标字母直接输出, 间隔为2的判断是否一个为标记g,一个为非标记做***替换 #include<iostre ...

  5. Unity3D使用过程中常见的20个问题

    1:天空盒有接缝怎么解决?答:在贴图导入设置里设置Wrap Mode为"Clamp". 2:DDS格式怎么不显示?答:Unity不支持DDS格式,Unity会将除DDS外的其他格式 ...

  6. Codeforces Round #229 (Div. 2) C. Inna and Candy Boxes 树状数组s

    C. Inna and Candy Boxes   Inna loves sweets very much. She has n closed present boxes lines up in a ...

  7. windows内核需要注意的

    修改windows内核函数 先屏蔽KdPrint 测试. Hook函数一律使用全局变量 妹的..KiTrap0E 修改.触发了已经断点.但是硬件断点Hook函数里只要使用KdPrint 就蓝屏

  8. 完善SQL农历转换函数

    -------------------------------------------------------------------- --  Author : 原著:          改编:ht ...

  9. Java可变参数讲解

    如果实现的多个方法,这些方法里面逻辑基本相同,唯一不同的是传递的参数的个数,可以使用可变参数可变参数的定义方法 数据类型...数组的名称,这个数组存储传递过来的参数,类似JavaScript注意点:  ...

  10. poj2796 维护区间栈//单调栈

    http://poj.org/problem?id=2796 题意:给你一段区间,需要你求出(在这段区间之类的最小值*这段区间所有元素之和)的最大值...... 例如: 6 3 1 6 4 5 2 以 ...