题目链接>>>>>>

题目大意:
给你一个数n(2 <= n <= 79),将0-9这十个数字分成两组组成两个5位数a, b(可以包含前导0,如02345也算),使得a / b = n;列出所有的可能答案。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath> using namespace std; int main()
{
int n, a[], first = ;
while (scanf("%d", &n) != EOF,n) {
if (first) {
first = ;
}
else {
printf("\n");
} //以上是两组数据之间输出空行的技巧
int num1 = , num2 = ;
int side = / n; //这里稍微降低了一下复杂度
int flag1 = ;
for (num1 = ; num1 <= side; num1++) {
int flag = ;
num2 = num1 * n;
a[] = num2 / ;
a[] = num2 / % ;
a[] = num2 / % ;
a[] = num2 / % ;
a[] = num2 % ;
a[] = num1 / ;
a[] = num1 / % ;
a[] = num1 / % ;
a[] = num1 / % ;
a[] = num1 % ;
for (int i = ; i < ; i++) {
for (int j = ; j < ; j++) {
if (j != i && a[i] == a[j]) { //这里判断10位数是否有重复的方法
flag = ;
}
}
}
if (flag) {
for (int i = ; i < ; i++)cout << a[i]; cout << " / "; //注意这里"/"和"="左右两边都有空格
for (int i = ; i < ; i++)cout << a[i]; cout << " = " << n << endl;
flag1 = ;
}
}
if (flag1 == ) {
printf("There are no solutions for %d.\n", n);
}
}
return ;
}

2018-04-08

UVA725 Division 除法【暴力】的更多相关文章

  1. UVA725 Division (暴力求解法入门)

    uva 725 Division Write a program that finds and displays all pairs of 5-digit numbers that between t ...

  2. uva 725 Division(暴力模拟)

    Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...

  3. Codeforces Beta Round #91 (Div. 2 Only) A. Lucky Division【暴力/判断是不是幸运数字4,7的倍数】

    A. Lucky Division time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. hdu 2615 Division(暴力)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2615 题解:挺简单的暴力枚举,小小的分治主要是看没人写题解就稍微写一下 #include <io ...

  5. UVa725 - Division

    #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int ...

  6. UVA 725 division【暴力枚举】

    [题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...

  7. uva725(除法)

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

  8. 3. Python 简介

    3. Python 简介 下面的例子中,输入和输出分别由大于号和句号提示符 ( >>> 和 ... ) 标注:如果想重现这些例子,就要在解释器的提示符后,输入 (提示符后面的) 那些 ...

  9. require.js实现js模块化编程(一)

    1.认识require.js: 官方文档:http://requirejs.org/RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的Requ ...

随机推荐

  1. Database学习 - mysql数据类型约束

    mysql数据类型 - 属性

  2. Java 线性表、栈、队列和优先队列

    1.集合 2.迭代器 例子: 3.线性表 List接口继承自Collection接口,有两个具体的类ArrayList或者LinkedList来创建一个线性表 数组线性表ArrayList Linke ...

  3. sublime3添加python编译系统

    好记性不如烂笔头 为sublime3添加python编译系统,这里使用的anonconda2中的python.exe(即python2.7版本) 步骤: (1)打开sublime,打开“工具-> ...

  4. MISC混杂设备 struct miscdevice /misc_register()/misc_deregister()【转】

    本文转自:http://blog.csdn.net/angle_birds/article/details/8330407 在Linux系统中,存在一类字符设备,他们共享一个主设备号(10),但此设备 ...

  5. weblogic实时监控开发

    参考api文档 https://docs.oracle.com/cd/E13222_01/wls/docs90/wlsmbeanref/core/index.html https://docs.ora ...

  6. Shell 中test 单中括号[] 双中括号[[]] 的区别

    Shell test 单中括号[] 双中括号[[]] 的区别 在写Shell脚本的时候,经常在写条件判断语句时不知道该用[] 还是 [[]],首先我们来看他们的类别: $type [ [[ test ...

  7. @RequestBody,@ResponseBody

    @RequestBody 作用: i) 该注解用于读取Request请求的body部分数据,使用系统默认配置的HttpMessageConverter进行解析,然后把相应的数据绑定到要返回的对象上: ...

  8. linux 平台core dump文件生成

    1. 在终端中输入ulimit -c 如果结果为0,说明当程序崩溃时,系统并不能生成core dump. root@hbg:/# ulimit -c0root@hbg:/# 2.使用ulimit -c ...

  9. 一台电脑,两个及多个git账号配置

    1. 生成两[三]个ssh公钥私钥 方法参照:http://www.cnblogs.com/fanbi/p/7772812.html第三步骤 假定其中一个是id_rsa, 另一个时id_rsa_two ...

  10. [学习笔记]JS计数器,闭包和localStorage

    1.前言 Javascript也算用了挺久了,为了得到一个变量,类似Java的静态变量的功能,我想到了很早以前学习JS的闭包,还有做俄罗斯方块的排行榜用到LocalStorage技术,所以想总结一下, ...