zoukankan      html  css  js  c++  java
  • Codeforces Round #357 (Div. 2) B

    B. Economy Game
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.

    Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).

    Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?

    Please help Kolya answer this question.

    Input

    The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.

    Output

    Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).

    Examples
    Input
    1359257
    Output
    YES
    Input
    17851817
    Output
    NO
    Note

    In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.

    题意:是否存在a*1234567+b*123456+c*1234=n 存在则输出YES 否则输出NO

    题解:暴力处理

     1 #include<iostream>
     2 #include<cstring>
     3 #include<cstdio>
     4 #include<algorithm>
     5 #define ll __int64
     6 ll n;
     7 int main()
     8 {
     9     scanf("%I64d",&n);
    10     int flag=0;
    11     for(int i=0;i<=n/1234567;i++)
    12     for(int j=0;j<=n/123456;j++)
    13     {
    14         if((i*1234567+j*123456<=n)&&(n-i*1234567-j*123456)%1234==0)
    15           {
    16               flag=1;
    17               break;
    18           }
    19     }
    20     if(flag)
    21     printf("YES
    ");
    22     else
    23     printf("NO
    ");
    24     
    25     return 0;
    26 }
  • 相关阅读:
    js右击事件
    css中的特殊居中
    js实现轮播图
    css画三角形
    Elasticsearch-5.5.0安装head插件
    Elasticsearch报错:NodeDisconnectedException[[][IP:9300][cluster:monitor/nodes/liveness] disc
    mybatis foreach多次遍历问题
    Java使用File.separator解决Win和Linux的路径问题
    WebStorm 代码提示快捷键
    springmvc 前台传日期(字符串) 后台用date接收封装失败(请求400)
  • 原文地址:https://www.cnblogs.com/hsd-/p/5612482.html
Copyright © 2011-2022 走看看