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

 

相关文章:

  • 2021-07-28
  • 2021-11-21
  • 2021-09-02
  • 2021-09-08
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-08-06
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
相关资源
相似解决方案