• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
dwtfukgv
博客园    首页    新随笔    联系   管理    订阅  订阅
CodeForces 681B Economy Game (暴力)

题意:给定一个数,问能不能 找到非负 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;
}

 

posted on 2016-06-22 18:24  dwtfukgv  阅读(416)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3