Codeforces Round #357 (Div. 2)-B. Economy Game
2016-06-15 09:26
246 查看
原题链接
暴力枚举1234567和123456的系数
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;
int main(){
int n;
cin >> n;
for(ll i = 0; i * 1234567 <= n; i++)
for(ll j = 0; j * 123456 + i * 1234567 <= n; j++){
int d = n - i * 1234567 - j * 123456;
if(d % 1234 == 0){
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}
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.
暴力枚举1234567和123456的系数
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;
int main(){
int n;
cin >> n;
for(ll i = 0; i * 1234567 <= n; i++)
for(ll j = 0; j * 123456 + i * 1234567 <= n; j++){
int d = n - i * 1234567 - j * 123456;
if(d % 1234 == 0){
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}
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.
相关文章推荐
- ArrayList和LinkedList的区别
- “Count Primes” and "Range Sum Query - Immutable"
- 使用 Linux 工具进行计算机取证
- Java Socket编程实例(二)- UDP基本使用
- RxJava 详解
- 广告机的例子(播放视频)
- 性能分析框架和性能监控平台
- java垃圾回收算法之-分代收集
- 彻底删除nginx
- leetcode No2. Add Two Numbers
- 链表程序
- 现代银行集中式业务系统及数据整合
- HTML5炫酷的特效代码下载
- Ubuntu安装JDK8
- 树莓派的播放器omxplayer
- 不用缩进的python
- dubbo--zookeeper面试中问题解答
- SAP表和字段
- java string与date类型转换
- linux下dos环境和unix环境转换