码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces 681B Economy Game (暴力)

时间:2016-06-22 19:01:35      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:

题意:给定一个数,问能不能 找到非负 a, b, c,使得 a × 1 234 567 + b × 123 456 + c × 1 234 = n

析:二重循环,去确定c。

代码如下:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;
const int aa = 1234567;
const int bb = 123456;
const int cc = 1234;


int main(){
    int n;   scanf("%d", &n);
    bool ok = false;
    for(int i = 0; i * aa <= n; ++i)
        for(int j = 0; i*aa + j*bb <= n; ++j)
            if((n-i*aa-j*bb)%cc == 0) {  puts("YES");  return 0;  }

    puts("NO");
    return 0;
}

 

CodeForces 681B Economy Game (暴力)

标签:

原文地址:http://www.cnblogs.com/dwtfukgv/p/5608145.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!