暴力(腊鸡)—— 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\n", ans);

    }
    //system("pause");
}

你可能感兴趣的:(ACM算法(题解):,数学)