Test instructions: A five-digit number that satisfies a shape such as a abcde/efghi=n
From i=1234 (because there can be leading 0) to 98765 enumerations, (I*n)/i=n, and then determine whether the individual digits are the same
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <queue>9#include <Set>Ten#include <algorithm> One using namespacestd; A -typedefLong LongLL; - inthash[1005]; the inta[1005],b[1005]; - - - intMain () { + intN,i,j,k,p,q,t,ans; - intok=1; + while(SCANF ("%d", &n)!=eof&&N) { A intflag=0, ans=0; at if(OK) ok=0; - Elseprintf"\ n"); - for(i=1234; i<=98765; i++){ -memset (Hash,0,sizeof(hash)); - if(i*n>100000) Break; - ina[1]=i/10000; hash[a[1]]++; -a[2]=i/ +%Ten; hash[a[2]]++; toa[3]=i/ -%Ten; hash[a[3]]++; +a[4]=i/Ten%Ten; hash[a[4]]++; -a[5]=i%Ten; hash[a[5]]++; the * intm=i*N; $ Panax Notoginsengb[1]=m/10000; hash[b[1]]++; -b[2]=m/ +%Ten; hash[b[2]]++; theb[3]=m/ -%Ten; hash[b[3]]++; +b[4]=m/Ten%Ten; hash[b[4]]++; Ab[5]=m%Ten; hash[b[5]]++; the + for(t=0; t<=9; t++){ - if(hash[t]!=1) Break; $ } $ - if(t<=9) flag=0; - Else{ theprintf"%05d/%05d =%d\n", m,i,n); -ans++;Wuyi } the } - Wu if(flag==0&&ans==0) printf ("There is no solutions for%d.\n", n); - } About return 0; $}
View Code
This topic from tle,tle,tle, to CE, to wa,= =555555555555
Go---go---go
UVa 725 Division