• Codeforces Round #357 (Div. 2) B. Economy Game 水题


    B. Economy Game

    题目连接:

    http://www.codeforces.com/contest/681/problem/B

    Description

    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).

    Sample Input

    1359257

    Sample Output

    YES

    Hint

    题意

    给你n,让你判断是否存在非负整数解a,b,c

    满足1234567a+123456b+1234c = n

    题解:

    暴力枚举a和b,然后o1判断c就好了

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        long long n;
        cin>>n;
        long long num1 = 1234567;
        long long num2 = 123456;
        long long num3 = 1234;
        for(long long i=0;i<=100;i++)
            for(long long j=0;j<=10000;j++)
                if(n>=i*num1+j*num2)
                {
                    long long p = n - i*num1-j*num2;
                    if(p%num3==0)
                    {
                        cout<<"YES"<<endl;
                        return 0;
                    }
                }
    
        cout<<"NO"<<endl;
    }
  • 相关阅读:
    ide 安装eval reset插件 Pycharm 永久破解
    Centos7.9安装RabbitMQ
    Linux环境下安装Centos7.9时没有图形界面的解决办法
    JS,对部分值base64解码
    consul 配置备份
    AutoMapper后遇到的“Missing map”与“Missing type map configuration”问题
    osg绘制圆柱体
    IfcFlowMovingDevice
    opencv absdiff
    IfcFlowMovingDeviceType
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5586153.html
Copyright © 2020-2023  润新知