UVA 725 Division(暴力枚举 简单)
2017-08-19 18:19
429 查看
UVA 725 Division
题意
输入n,输出满足abcde/fghij=n的表达式(从小到大),其中a~j是0~9的一个排列解决
枚举fghij,算出abcde,然后判断一下0~9的数字有没有被无重复的用完就是注意一下,0~9的每一个数字都要用到
int used[10]; bool judge(int a,int b) { if(b>98765) return false; memset(used,0,sizeof(used)); if(a<10000) used[0]=1; //形如0xxxx的数字中,0已经被使用 while(a) { used[a%10]++; a/=10; } while(b) { used[b%10]++; b/=10; } int sum=0; rep(i,0,10) if(used[i]>1||used[i]==0) return false; return true; } int main() { //open(); //out(); int n,cases=0; while(1) { scanf("%d",&n); if(!n) break; if(cases++) printf("\n"); int cnt=0; rep(i,1234,100000){ //枚举fghij,算出abcde,然后judge一下 if(judge(i,i*n)){ //i是除数,i*n是被除数 printf("%05d / %05d = %d\n",i*n,i,n); cnt++; } } if(!cnt) printf("There are no solutions for %d.\n",n); } }
相关文章推荐
- UVa 725 Division --- 简单枚举
- uva 725 Division(暴力枚举) 解题心得
- UVa - 725 - Division(暴力枚举)
- UVA 725 Division ( 找出 abcde / fghij = N的形式—— 暴力枚举 )
- uva 725 Division(暴力枚举)
- 暴力枚举 UVA 725 Division
- uva 725 Division 简单枚举
- UVA725 Division【暴力枚举】
- UVa - 725 Division ( 暴力枚举 )
- uva 725 DIVISION (暴力枚举)
- UVA - 725 Division (暴力枚举)
- 简单枚举UVa725-division (abcde / fghij = n)
- 简单枚举 uva725
- Uva 725 Division (技巧暴力)
- UVa 725 Division 【暴力入门】
- uva 725 Division 暴力求解入门
- 例题7-1 UVa725 Division(枚举)
- Division UVA - 725(暴力)
- Uva725 Division【dfs枚举】【例题7-1】
- UVA 725 Division (暴力)