Economy Game(暴力)

点击打开链接

题意分析:给定一个数n,判断是否有整数a,b,c满足a × 1 234 567 + b × 123 456 + c × 1 234 = n

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include 
using namespace std;
const int maxn = 200010;
char s[maxn],t[maxn];
int main()
{
    long long n;
    scanf("%I64d",&n);
    int flag = 0,flag1 = 0,flag2 = 0,flag3 = 0;
    for(int i = 0; ; i++)
    {
        long long ii = i * 1234567;
        if(ii > n || flag == 10) break;
        for(int j = 0; ; j++)
        {
            long long jj = j * 123456;
            if(ii + jj > n)   break;
            double kk = (double)(n - ii - jj) / 1234;
            if(kk == (int)kk) flag = 10;
            if(flag == 10)    break;
                    
        }
//        if(flag2 == 1) break;
    }
    if(flag == 10) printf("YES\n");
    else  printf("NO\n");
    return 0;
}


你可能感兴趣的:(暴力,OJ,——,CodeForces)