UVA725 Division 除法【暴力】
题目链接>>>>>>
题目大意:
给你一个数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 除法【暴力】的更多相关文章
- UVA725 Division (暴力求解法入门)
uva 725 Division Write a program that finds and displays all pairs of 5-digit numbers that between t ...
- uva 725 Division(暴力模拟)
Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...
- 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 ...
- hdu 2615 Division(暴力)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2615 题解:挺简单的暴力枚举,小小的分治主要是看没人写题解就稍微写一下 #include <io ...
- UVa725 - Division
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int ...
- UVA 725 division【暴力枚举】
[题意]:输入正整数n,用0~9这10个数字不重复组成两个五位数abcde和fghij,使得abcde/fghij的商为n,按顺序输出所有结果.如果没有找到则输出“There are no solut ...
- uva725(除法)
Description Write a program that finds and displays all pairs of 5-digit numbers that between them u ...
- 3. Python 简介
3. Python 简介 下面的例子中,输入和输出分别由大于号和句号提示符 ( >>> 和 ... ) 标注:如果想重现这些例子,就要在解释器的提示符后,输入 (提示符后面的) 那些 ...
- require.js实现js模块化编程(一)
1.认识require.js: 官方文档:http://requirejs.org/RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的Requ ...
随机推荐
- Python巧用正则表达式,完成接口参数替换
最近给Python11期的小朋友们上课,遇到了一个参数替换的问题,首先描述下场景: 需要参数化的数据如下所示: 这个时候如果利用单纯的if判断和字符串的find和replace方法,做起来是非常不明智 ...
- Android NDK编程
1.首先需要声明native方法: public native String helloWorldNdk(); public native String hello_World_Ndk(); 2.然后 ...
- 文件打包(.zip)并返回打压缩包存放路径
1.由于公司需要将一个或多个视频进行打包,格式如下图: 2.创建zipUtil工具包: package com.seegot.util; import java.io.BufferedOutputSt ...
- swift计算 switch case
var year = var month = var day = ; let daysOfFeb = year % == && year% != || year % == ?: var ...
- python中argparse
python中argparse 在很多编程语言中,运行程序可以直接使用function(a,b,……)运行程序,但是在python中就无法实现,那么我们如何在命令行中传递参数呢?在python的中,有 ...
- Raw Socket vs Stream Socket vs datagram socket,原始套接字与流式套接字与数据报套接字
https://opensourceforu.com/2015/03/a-guide-to-using-raw-sockets/ In this tutorial, lets take a look ...
- Jenkins与网站代码上线解决方案【转】
转自 Jenkins与网站代码上线解决方案 - 惨绿少年 https://www.nmtui.com/clsn/lx524.html 1.1 前言 Jenkins是一个用Java编写的开源的持续集成工 ...
- nodejs async series 小白向
async.series({ flag1:function(done){ //flag1 是一个流程标识,用户自定义 //逻辑处理 done(null,"返回结果&qu ...
- 阿里云配置ssl证书服务遇到的几个问题和解决方法
系统环境: 系统:阿里云ECS CentOS6.5+Apache2.4.10 前提:公司需要将站点升级到使用SSL证书服务(https) 实践执行:在阿里云的证书服务--选择了一个免费的证书服务,毕竟 ...
- python+selenium十一:jQuery和js语法、js处理iframe
selenium 执行jQuery/js语法 driver.execute_script(jQuery/js) 1.jQuery jQuery只支持css语法: jquery = '$(CSS).va ...