폭력 (납 계) - ACdream 1068

  • 제목 링크:http://acdream.info/problem?pid=1068
  • 제목: 제목 보기
  • 분석: 폭력, (MD, 직접 검색 하면 돼)
  • AC 코드:
  • /*************************************************************************
        > File Name: test.cpp
        > Author: Akira 
        > Mail: [email protected] 
     ************************************************************************/
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    typedef long long LL;
    typedef unsigned long long ULL;
    typedef long double LD;
    #define MST(a,b) memset(a,b,sizeof(a))
    #define CLR(a) MST(a,0)
    #define Sqr(a) ((a)*(a))
    using namespace std;
    
    #define MaxN 100000
    #define MaxM MaxN*10
    #define INF 0x3f3f3f3f
    #define bug cout<<88888888<
    #define MIN(x,y) (x
    #define MAX(x,y) (x>y?x:y)
    
    template<typename _> inline void scan(_& t)
    {
        int c;
        while((c = getchar()) < '0' || c > '9');
        t = c - '0';
        while((c = getchar()) >= '0' && c <= '9') t = t * 10 + c - '0';
    }
    template<typename _> inline void print(_ x)
    {
        int len = 0, p[20];
        if(x < 0) putchar('-'), x = -x;
        while(x) p[++len] = x % 10, x /= 10;
        if(!len) p[++len] = 0;
        while(len) putchar(p[len--] + '0');
    }
    
    LL A, B, S;
    
    
    
    bool judge(LL x)
    {
        LL sum = 0;
        while(x)
        {
            sum += x%10;
            x/= 10;
        }
        if(sum == S) return true;
        else return false;
    }
    
    int main()
    {
        while(~scanf("%lld%lld%lld", &A, &B, &S))
        {
            LL ans = A;
            while(ans<=B && !judge(ans))
            {
                ans++;
            }
            printf("%lld
    "
    , ans); } //system("pause"); }

    좋은 웹페이지 즐겨찾기