除法

题目链接: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. 顺序表C语言版

    #include <stdio.h> /* * 顺序表最多输入N个数 */ #define N 10 #define OK 1 #define ERROR -1 struct sequeu ...

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

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

  3. 外观模式/facade模式/结构型模式

    外观模式 为子系统中的一组接口提供一个一致的界面, Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 外观模式三要素(client-facade-subSystem) 外观角色 ...

  4. JS 正则表达式详解

    在此提供相关的链接,请访问: http://www.cnblogs.com/dolphinX/p/3486214.html http://www.cnblogs.com/dolphinX/p/3486 ...

  5. Unity2D 之 Sprite点击事件

    以下方法纯属我YY,切勿当真!!! 给 Sprite添加点击事件步骤: 1. 创建一个 Sprite 2. 给Sprite添加一个 Box Collider 2D 3. 将如果脚本放到Sprite上: ...

  6. ASP.NET MVC使用过滤器进行权限控制

    1.新建MVC项目 2.找到Models文件夹,新建 LoginCheckFilterAttribute 类 public class LoginCheckFilterAttribute : Acti ...

  7. 解决Eclipse建Maven项目module无法转换为2.3

    Maven项目在Project Facets里面修改Dynamic web module为2.3的时候就会出现Cannot change version of project facet Dynami ...

  8. caffe中添加local层

    下载caffe-local,解压缩; 修改makefile.config:我是将cuudn注释掉,去掉cpu_only的注释; make all make test(其中local_test出错,将文 ...

  9. DSP using MATLAB 示例Example3.23

    代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...

  10. Android和SQLite版本对应关系

    Android和SQLite版本对应关系 今天Xamarin群有人问到Android和SQLite版本如何对应,顺手查了一下,贴出来. SQLite 3.8.4.3: • 21-5.0-Lollipo ...