Codeforces Round #357 (Div. 2) B. Economy Game
来源:互联网 发布:私人定制软件 编辑:程序博客网 时间:2024/06/05 14:24
B. Economy Game
1 second
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.
题目大意:
给你一个数,问你能否仅由1234567,123456,1234组成
题目分析:
我是暴力莽一波,然后剪枝,剪当然是剪n大的啦。
#include<bits/stdc++.h>using namespace std;const int maxn=1e9+7;int flag;int main(){ int n; scanf("%d",&n); flag=0; int n1=n/1234567; int n2=n/123456; for(int i=0;i<=n1;i++) for(int j=0;j<=n2;j++) { int tmp=n-1234567*i-123456*j; if(tmp==0){flag=1;break;} else if(tmp<1234)break; if((n-1234567*i-123456*j)%1234==0){flag=1;break;} } if(flag)puts("YES"); else puts("NO");}
- Codeforces Round #357 (Div. 2) B. Economy Game
- Codeforces Round #357 (Div. 2)-B. Economy Game
- Codeforces Round #357 (Div. 2) B. Economy Game
- Codeforces Round #357 (Div. 2) B. Economy Game
- Codeforces Round #357 (Div. 2) B. Economy Game (暴力)
- Codeforces Round #357 (Div. 2) B Economy Game(水题)
- Codeforces-Round-#357-(Div.-2)-Economy-Game
- CodeForces 681B Economy Game
- CodeForces - 681B Economy Game
- CodeForces-681B.Economy Game
- CodeForces 681B Economy Game
- CodeForces 681B Economy Game (暴力)
- 【codeforces 681B】【优化循环】Economy Game
- Codeforces Round #128 (Div. 2) B. Game on Paper
- Codeforces Round #245 (Div. 2) B - Balls Game
- Codeforces Round #263 (Div. 2)B. Appleman and Card Game
- Codeforces Round #263 (Div. 2)B. Appleman and Card Game
- Codeforces Round #263 (Div. 2)-B. Appleman and Card Game
- Retrofit官网翻译
- c++笔记(1)
- Android的Touch Mode
- 抽象类 和 接口
- [SCOI2005] 最大子矩阵
- Codeforces Round #357 (Div. 2) B. Economy Game
- Android 常用知识总结2
- elasticsearch-jdbc实现MySQL同步到ElasticSearch深入详解
- 292. Nim Game
- Android 热更新实现原理及代码分析
- Android中的View基础
- 美食节
- 获取浏览器类型
- Android toolbar menu 字体点击样式