Division
来源:互联网 发布:js无法删除cookie 编辑:程序博客网 时间:2024/04/29 21:40
A - Division
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluDescription
Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the first number divided by the second is equal to an integer N, where . That is,
abcde / fghij =N
where each letter represents a different digit. The first digit of one of the numerals is allowed to be zero.
Input
Each line of the input file consists of a valid integer N. An input of zero is to terminate the program.Output
Your program have to display ALL qualifying pairs of numerals, sorted by increasing numerator (and, of course, denominator).Your output should be in the following general form:
xxxxx / xxxxx =N
xxxxx / xxxxx =N
.
.
In case there are no pairs of numerals satisfying the condition, you must write ``There are no solutions for N.". Separate the output for two different values of N by a blank line.
Sample Input
61620
Sample Output
There are no solutions for 61.79546 / 01283 = 6294736 / 01528 = 62
好坑的格式,竟然/和=两边还有空格。。。
AC代码:
#include <iostream>#include <cstring>#include <cstdio>using namespace std;int n,a[11],f;int jugde(int t){a[t/10000]++;a[t/1000%10]++;a[t%1000/100]++;a[t%100/10]++;a[t%10]++;for(int i=0;i<10;++i){if (a[i]>1){return 0;}}return 1;}int main(){int cnt=0;while (scanf("%d",&n)&&n){f=1;if(cnt++)printf("\n");for (int i=1234;i*n<=98765;++i){memset(a,0,sizeof(a));if (jugde(i)&&jugde(i*n)){f=0;if(i/10000){ printf("%d / %d = %d\n",i*n,i,n);}else{ printf("%d / 0%d = %d\n",i*n,i,n);}}}if(f)printf("There are no solutions for %d.\n",n);}return 0;}
0 0
- Division
- Division
- Division
- Division
- Division
- Division Operation
- pku_3140_Contestants Division
- Set Division
- Lucky Division
- fzuoj1607Greedy division
- Greedy division
- uva725-Division
- Polygon Division
- [HDU3480] Division
- UVa_725 - Division
- UVa725 Division
- UVa725 - Division
- 725 - Division
- 旋转和缩放视图
- 编译Ogre1.8.1 for vs2010
- java基础—计算: 2012-3-17"到"2012-4-6"中间有多少天?
- 【BC#24 1002 HDOJ 5273】Dylans loves sequence
- 15HD_OJ——Max Sun
- Division
- 黑马day06 EL表达式获取数据
- UICollectionView 的使用详解
- 黑马程序员---2015.6.20java基础笔记---集合类--ArrayList---LinkedList---HashSet
- C# ReadProcessMemory/OpenProcess/CloseHandle用法
- A. Vanya and Table(Codeforces Round #308 (Div. 2))
- CMake 编译时出现错误 coffe转换到 COFF 期间失败: 文件无效或损坏
- 雾里探花之计算机硬件及组成原理(基础知识一)
- cocos studio lua 项目没有 print 输出解决办法