The nineth session of Anhui University College Students Program Design Competition Network qualifier D-buy and buy

Source: Internet
Author: User

D. Buy buy time limit:1000 ms Memory limit:64 MB
Total submission:286 submission accepted:56 Description one day Alice opened her daily game and found that she had n game coins in it, and she wanted to spend it all.
Now you can buy a total of three props, respectively, the house (1,234,567 games worth each), the car (123,456 games worth each), the computer (each value of 1234 game coins).
Now she wants to know if you can spend all of the n game coins by buying these three props.
Input the first line, a number T (1<=t<=100). Represents the number of test data.
For each set of test data, an integer n (1<=n<=1000000000) represents the current game currency.
Output outputs n rows, "YES" or "no" per line, indicating that she can or may not spend all of the game currency.
Sample Input

Original Transformed
2
1359257
17851817

Sample Output
Original Transformed
YES
NO

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int bag[3] = {1234567, 123456, 1234};
int main ()
{
    int t;
    scanf ("%d", &t);
    while (t--)
    {
        long long;
        int flag = 0;
        scanf ("%i64d", &money);
        for (int i = 0; I <= money/bag[0], i++)
        {for (int j = 0; J <= (Money-bag[0] * i)/bag[1]; j +)
        {
         long Long    sum = i * bag[0] + j * Bag[1];
            if ((money-sum)% bag[2] = = 0)
                {printf ("yes\n"); flag = 1; break;}
        }
        if (flag) break;
        if (!flag) printf ("no\n");
 
    return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.