zoukankan      html  css  js  c++  java
  • UVA 725

    UVA 725

    sprintf(buf, "%05d%05d", abcde, fghij);

    0补位,避免153078 / 02469 = 62数据出现。

    153078 / 02469 = 62中,153078 / 2469 = 62,由于没有补位,也整好满足相除等于62且从0到9

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    
    using namespace std;
    
    int main() 
    {
        int n ;
        char buf[20];
        while(scanf("%d", &n) == 1 && n) 
        {
            int cnt = 0;
            for(int fghij = 1234;  ; fghij++) 
            {
                int abcde = fghij * n;
                sprintf(buf, "%05d%05d", abcde, fghij);
                // sprintf(buf, "%d%d", abcde, fghij);
                if(strlen(buf) > 10)    break;
                sort(buf, buf+10);
                bool ok = true;
                for(int i = 0; i < 10; i++)
                if(buf[i] != '0' + i) ok = false;
                if(ok) 
                {
                    cnt++;
                    printf("%05d / %05d = %d
    ", abcde, fghij, n);
                }
            }
            if(!cnt) printf("There are no solutions for %d.
    ", n);
        }
        return 0;
    }
    
    透过泪水看到希望
  • 相关阅读:
    多表查询 left join
    对JS关于对象创建的几种方式的整理
    常见正则表达式
    spring
    富文本编辑器
    Struts2快速入门
    一个MySql Sql 优化技巧分享
    maven
    day3
    Spring MVC
  • 原文地址:https://www.cnblogs.com/ronnielee/p/9495170.html
Copyright © 2011-2022 走看看