Codeforces_397B_On Corruption and Numbers(数论)
2014-02-27 21:05
344 查看
B. On Corruption and Numbers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what profession he wants to get. At school,
he had bad grades in all subjects, and it's only thanks to wealthy parents that he was able to obtain the graduation certificate.
The situation is complicated by the fact that each high education institution has the determined amount of voluntary donations, paid by the new students for admission — ni berubleys.
He cannot pay more than ni,
because then the difference between the paid amount and ni can
be regarded as a bribe!
Each rector is wearing the distinctive uniform of his university. Therefore, the uniform's pockets cannot contain coins of denomination more than ri.
The rector also does not carry coins of denomination less than li in
his pocket — because if everyone pays him with so small coins, they gather a lot of weight and the pocket tears. Therefore, a donation can be paid only by coins of denomination x berubleys,
where li ≤ x ≤ ri (Berland
uses coins of any positive integer denomination). Alexey can use the coins of different denominations and he can use the coins of the same denomination any number of times. When Alexey was first confronted with such orders, he was puzzled because it turned
out that not all universities can accept him! Alexey is very afraid of going into the army (even though he had long wanted to get the green uniform, but his dad says that the army bullies will beat his son and he cannot pay to ensure the boy's safety). So,
Alexey wants to know for sure which universities he can enter so that he could quickly choose his alma mater.
Thanks to the parents, Alexey is not limited in money and we can assume that he has an unlimited number of coins of each type.
In other words, you are given t requests, each of them contains numbers ni, li, ri.
For each query you need to answer, whether it is possible to gather the sum of exactly ni berubleys
using only coins with an integer denomination from li to ri berubleys.
You can use coins of different denominations. Coins of each denomination can be used any number of times.
Input
The first line contains the number of universities t, (1 ≤ t ≤ 1000)
Each of the next t lines contain three space-separated integers: ni, li, ri (1 ≤ ni, li, ri ≤ 109; li ≤ ri).
Output
For each query print on a single line: either "Yes", if Alexey can enter the university, or "No"
otherwise.
Sample test(s)
input
output
Note
You can pay the donation to the first university with two coins: one of denomination 2 and one of denomination 3 berubleys. The donation to the second university cannot be paid.
题型:数论
题意:
在[l , r]的面值范围内能否构成n元。
分析:
全部用最少的面值的话需要n/l张,假设用同样多张的面值为r的钱,那么就是n/l*r元。
如果n∈[n/l , n/l*r],则必然存在一种构成n元的方法;
如果n不在这个区间,则不然不能构成n元。
代码:
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what profession he wants to get. At school,
he had bad grades in all subjects, and it's only thanks to wealthy parents that he was able to obtain the graduation certificate.
The situation is complicated by the fact that each high education institution has the determined amount of voluntary donations, paid by the new students for admission — ni berubleys.
He cannot pay more than ni,
because then the difference between the paid amount and ni can
be regarded as a bribe!
Each rector is wearing the distinctive uniform of his university. Therefore, the uniform's pockets cannot contain coins of denomination more than ri.
The rector also does not carry coins of denomination less than li in
his pocket — because if everyone pays him with so small coins, they gather a lot of weight and the pocket tears. Therefore, a donation can be paid only by coins of denomination x berubleys,
where li ≤ x ≤ ri (Berland
uses coins of any positive integer denomination). Alexey can use the coins of different denominations and he can use the coins of the same denomination any number of times. When Alexey was first confronted with such orders, he was puzzled because it turned
out that not all universities can accept him! Alexey is very afraid of going into the army (even though he had long wanted to get the green uniform, but his dad says that the army bullies will beat his son and he cannot pay to ensure the boy's safety). So,
Alexey wants to know for sure which universities he can enter so that he could quickly choose his alma mater.
Thanks to the parents, Alexey is not limited in money and we can assume that he has an unlimited number of coins of each type.
In other words, you are given t requests, each of them contains numbers ni, li, ri.
For each query you need to answer, whether it is possible to gather the sum of exactly ni berubleys
using only coins with an integer denomination from li to ri berubleys.
You can use coins of different denominations. Coins of each denomination can be used any number of times.
Input
The first line contains the number of universities t, (1 ≤ t ≤ 1000)
Each of the next t lines contain three space-separated integers: ni, li, ri (1 ≤ ni, li, ri ≤ 109; li ≤ ri).
Output
For each query print on a single line: either "Yes", if Alexey can enter the university, or "No"
otherwise.
Sample test(s)
input
2 5 2 3 6 4 5
output
Yes No
Note
You can pay the donation to the first university with two coins: one of denomination 2 and one of denomination 3 berubleys. The donation to the second university cannot be paid.
题型:数论
题意:
在[l , r]的面值范围内能否构成n元。
分析:
全部用最少的面值的话需要n/l张,假设用同样多张的面值为r的钱,那么就是n/l*r元。
如果n∈[n/l , n/l*r],则必然存在一种构成n元的方法;
如果n不在这个区间,则不然不能构成n元。
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #define LL long long using namespace std; int t; int main() { LL n,l,r; while(~scanf("%d",&t)) { while(t--) { cin>>n>>l>>r; if(n/l*r>=n) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } return 0; }
相关文章推荐
- 【CodeForces 397B 】On Corruption and Numbers(规律)
- 【简单题】【数学】-CF-397B-On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B.On Corruption and Numbers(整数拆分)
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- codefoeces B 397 - On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- Codeforces 385C Bear and Prime Numbers(数论)
- Codeforces 385C Bear and Prime Numbers(数论)
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers 题解
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers
- On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B - On Corruption and Numbers