UVa 725 Division

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.