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