Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=412
Direct enumeration. In the code, we give a method of using bit arithmetic to judge whether there are any duplicates in the number.
Complete code:
01./*0.032s*/
.
#include <cstdio>
04.const long long maxn = 9876543210LL;
06.inline bool Check (long long N)
07.{
L. int i, cnt = 0;
A. While (n)
. {One
. i = 1 << (n%); if (CNT & i) return false; cnt |= i; n/=;
. return true;
.
19.int Main ()
20.{ long long s1, S2, N; int t; scanf ("%d", &t);
While (t--)
. { scanf ("%lld", &n);
For (s2 = 1; s2 <= maxn; ++s2)
. { s1 = n * S2; if (S1 > Maxn) break; if (check (S2) && check (S1)) printf ("%lld/%lld =%lld\n", s1, S2, n);
. if (t) Putchar (a);
. return 0;
36.}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/