UVA725 Division 除法【暴力】
2024-10-10 21:32:25
题目链接>>>>>>
题目大意:
给你一个数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
最新文章
- Android之Activity状态的保存和恢复
- java web的开发 知识要点
- iwebshop 订单存库修改为下单件库存
- [DataTable]控件排序事件中用DataView及DataTable排序
- minicom installation and configuration on ubuntu
- cocos2dx入门分析 hello world
- Linux进程实时监控 - htop
- JUnit三分钟教程 ---- 快速起步
- CentOS 6.4安装(超级详细图解教程)
- 如何捕获Wince下form程序的全局异常
- linux内存源码分析 - 内存压缩(同步关系)
- hdu4064 三进制状态压缩 好题!
- JavaScript原型、闭包、继承和原型链等等总结
- Celery 在Windows下启动worker时出现错误:ValueError: not enough values to unpack (expected 3, got 0)
- Retrofit添加自定义转换器
- mongodb副本集数据同步的踩坑
- python判断文件和文件夹是否存在、没有则创建文件夹
- box-sizing 盒子模型不改变大小
- jquery中lhgdialog插件(一)
- Java方法命名之“由简入繁”原则
热门文章
- 2017CCPC秦皇岛 E题String of CCPC&;&;ZOJ3985【模拟】
- Ubuntu16.04搭建QingdaoU(docker一键式部署)
- HDFS2.0架构以及HA详解
- window.location详解
- Android UI组件之自定义控件实现IP地址控件
- 重新看halcon模板匹配
- Informatic学习总结_day02
- MPI 在Windows10 上安装,使用VS2013编译生成可执行程序
- OCM_第十天课程:Section5&mdash;》数据仓库
- Win7 x64 svn 服务器搭建