Codeforces Round #357 (Div. 2) B. Economy Game
2016-06-15 10:38
155 查看
题目链接:http://codeforces.com/contest/681/problem/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
(for1 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
thata × 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
output
input
output
Note
In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending1 234 567 + 123 456 + 1234 = 1 359 257 game-coins
in total.
题意
给你一个数字n,让你判断是否存在三个非负整数a,b,c,使a*1234567+b*123456+c*1234等于n。
代码
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
(for1 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
thata × 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, spending1 234 567 + 123 456 + 1234 = 1 359 257 game-coins
in total.
题意
给你一个数字n,让你判断是否存在三个非负整数a,b,c,使a*1234567+b*123456+c*1234等于n。
代码
//<span style="font-size:12px;">暴力a,b,判断是否</span>能整除1234。 #include <stdio.h> int main() { int a,b,flag; __int64 n; scanf("%I64d",&n); flag=0; for(a=0;100>a&&flag==0;a++){ for(b=0;1000>b&&flag==0;b++){ if(n<a*1234567+b*123456){ break; } if((n-a*1234567-b*123456)%1234==0){ flag=1; break; } } } if(flag==1){ printf("YES\n"); } else{ printf("NO\n"); } return 0; }
相关文章推荐
- 我自己的python开发环境
- 委托异步调用方法
- xml中使用foreach遍历对象
- (转)mongodb分片
- python version 2.7 required,which was not found in the registry
- android opengl学习推荐博文
- iOS文字上下滚动效果的实现
- Swift anyobject 如何把value强转成String类型,或者判断value的类型?
- recyclerView简单解析
- Camera Calibration Toolbox for Matlab
- 不同卫星系统GPS报文头
- IOS 富文本 ,设置行间距、字间距,计算高度(转载组合而成)
- ionic-adventures
- find
- SimpleDateFormat 常规用法
- cocos2d-x 3.x学习之FadeAction
- ubuntu用户添加adduser, useradd并给予sudo权限
- iOS调用系统电话,UIAlertController的基本使用
- GCD介绍(三)-Dispatch Sources
- MQTT协议在nodejs中的使用