UVA - 725 Division

题目链接:

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35442

这里写图片描述
这里写图片描述

暴力搜索。。。

wrong wrong wrong!!!没完了。。

/*************************************************************************
    > File Name: UVa_725.cpp
    > Author: dulun
    > Mail: dulun@xiyoulinux.org
    > Created Time: 2016年03月18日 星期五 20时44分13秒
 ************************************************************************/

#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;

const int N = 50086;

bool check(int a, int b)
{
    if(b >98765) return 0;
    int v[15] = {0};
    memset(v, 0, sizeof(v));
    if(a < 10000) v[0] = 1;
    while(a)
    {
        v[a%10] = 1;
        a /= 10;
    }
    while(b)
    {
        v[b%10] = 1;
        b /= 10;
    }
    int sum = 0;
    for(int i = 0; i < 10; i++)
    {
        sum += v[i];
    }
    return (sum == 10);

}

int main()
{
    int n, t = 0;
    while(~scanf("%d", &n) && n)
    {
        if(t++) printf("\n");
        int flag = 0;
        for(int i = 1234; i < 50000; i++)
        {
            if(check(i, i*n))
            {
                printf("%05d / %05d = %d\n", i*n, i, n);
                flag++;
            }
        }
        if(flag == 0) printf("There are no solutions for %d.\n", n);
    }


    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值