Topic Portal
1 /*2 violence: Judging for every number, whether the numbers are all used once3 */4#include <cstdio>5#include <iostream>6#include <algorithm>7#include <cmath>8#include <cstring>9#include <string>Ten#include <map> One#include <Set> A#include <queue> - using namespacestd; - the Const intMAXN = 1e4 +Ten; - Const intINF =0x3f3f3f3f; - intvis[Ten]; - + BOOLOkintXinty) - { +memset (Vis,0,sizeof(Vis)); A for(intI=1; i<=5; ++i) at { -vis[x%Ten]++; vis[y%Ten]++; - if(vis[x%Ten] >1|| vis[y%Ten] >1)return false; -X/=Ten; Y/=Ten; - } - in return true; - } to + intMainvoid)//UVA 725 Division - { the //freopen ("uva_725.in", "R", stdin); * $ intN, cnt =0;Panax Notoginseng while(SCANF ("%d", &n) = =1) - { the if(n = =0) Break; + if(cnt++) puts (""); A the intone =0; + for(intI=1234; i<=100000/n; ++i) - { $ if(I * n >98765) Break; $ if(OK (i, i*n) = =true) - { -printf ("%05d/%05d =%d\n", N*i, I, N); one++; the } - }Wuyi the if(!one) printf ("There is no solutions for%d.\n", n); - } Wu - return 0; About } $ - - /* - There is no solutions for a. A */
Violent enumeration of UVA 725 Division