zoukankan      html  css  js  c++  java
  • hdu 1333 Smith Numbers

    刚开始没看清题意,要找的数一定要是素数

    #include<iostream>
    #include<stdio.h>
    #include<algorithm>
    #include<iomanip>
    #include<cmath>
    #include<string>
    using namespace std;
    int
    fun(int n)
    {

        int
    ans=0;
        while
    (n)
        {

            ans+=n%10;
            n/=10;
        }

        return
    ans;
    }

    int
    main()
    {

        int
    n,i,j,k,sum,m;
        while
    (scanf("%d",&n)&&n)
        {

            for
    (k=n+1;;k++)
            {

                n=k;sum=0;m=0;
                for
    (i=2;i<=sqrt(n*1.0);i++)
                {

                    while
    (n%i==0)
                    {

                        m++;
                        sum+=fun(i);
                        n/=i;
                    }
                }

                if
    (n>1) sum+=fun(n);
                if
    (sum==fun(k)&&m)
                    break
    ;
            }

            printf("%d ",k);
        }

        return
    0;
    }

  • 相关阅读:
    office2007快捷键
    To be solved
    网址Favorites
    C#网址
    developer's website
    Visual Studio快捷键
    如何跟进大客户?
    这些话让我们意识到流程的重要性
    恭祝大家情人节快乐!
    知已知彼,大客户管理10策
  • 原文地址:https://www.cnblogs.com/xin-hua/p/3194579.html
Copyright © 2011-2022 走看看