| 20701 Division |
| Difficulty level: B; run time limit: 1000ms; operating space limit: 51200KB; code length limit: 2000000B |
| Question Description |
| Enter positive integer n to output all ABCDE and fghij that satisfy the expression abcde/fghij=n in order from small to large, where a~j happens to be an arrangement of the number 0~9. If the number of test instructions is not met, the output is 0. The five-digit number mentioned in the subject can include a leading 0, such as 01234, which is also called a five-digit number. |
| Input |
| A positive integer n |
| Output |
| Several rows, each of which consists of two qualifying five-bit positive integers (two of each row are first large and small), and two numbers are separated by a space. |
| Input example |
| 62 |
| Output example |
79546 01283 94736 01528 |
| Other Notes |
| Data range 2≤n≤79; from small to Osashi in the title, the first number of each row of output data is the order of small to large. |
The key: SPRITF practice, there are several pits:
1.SPRINTF will automatically fill in the back after one.
2. Not satisfied test instructions output 0 ...
1#include <iostream>2#include <cstdio>3#include <cmath>4#include <algorithm>5#include <queue>6#include <cstring>7 #definePAU Putchar (")8 #defineENT Putchar (' \ n ')9 using namespacestd;TenInlineintRead () { One intx=0, sig=1;CharCh=GetChar (); A while(!isdigit (CH)) {if(ch=='-') sig=-1; ch=GetChar ();} - while(IsDigit (CH)) x=Ten*x+ch-'0', ch=GetChar (); - returnx*=Sig; the } -InlinevoidWriteintx) { - if(x==0) {Putchar ('0');return;}if(x<0) Putchar ('-'), x=-x; - intlen=0, buf[ the]; while(x) buf[len++]=x%Ten, x/=Ten; + for(inti=len-1; i>=0; i--) Putchar (buf[i]+'0');return; - } + intKBOOLflag=false; A voidPrintd (intS) { at if(s<10000) Write (0); write (S);return; - } - voidCheckintS) { - if(s%k!=0)return; - Chars[ One]={'0'};BOOLvis[ One]={};sprintf ((s<10000? s+1: s),"%d", S);intt=s/K; -s[5]='0'; sprintf (t<10000? s+6: s+5),"%d", T); for(intI=0;i<Ten; i++)if(vis[s[i]-'0'])return;Elsevis[s[i]-'0']=true; inPrintd (S); Pau;printd (T); ent;flag=true; - return; to } + voidinit () { -k=read (); the for(ints=1234; s<=98765; s++) Check (S); * if(!flag) Write (0); $ return;Panax Notoginseng } - voidWork () { the return; + } A voidprint () { the return; + } - intMain () {init (); work ();p rint ();return 0;}
COJ 0046 20701 Division