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
2
1359257
17851817
Sample Output
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;
}