Codeforces Round #232 (Div. 2) B. On Corruption and Numbers
来源:互联网 发布:ae2015cc mac破解版 编辑:程序博客网 时间:2024/05/16 08:57
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 andni 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 xberubleys, 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.
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).
For each query print on a single line: either "Yes", if Alexey can enter the university, or "No" otherwise.
25 2 36 4 5
YesNo
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.
B题蛮好理解的, 代码也很短, 一开始思考有些漏洞, 好在还是自己cha出来了
为了判断整数n能否被在l到r区间内一些整数拆分(可重复), 可以证明r*(n/l)到l*(n/r)之间所有数都能被(l,r)拆分
所以当l,r不整除n时只需判断n/r是否大于n/l即可, 这时区间内包括了n
另外当n能被l或者r整除时也存在拆分的方案.
我大致就是这个思路了
#include <stdio.h>main(){ int i, j, T, n, l, r; scanf("%d",&T); while(T--){ scanf("%d%d%d",&n,&l,&r); if(n/l>n/r||n%l==0||n%r==0) puts("Yes"); else puts("No"); } return 0;}
现在实力还做不出这一期的C题, 大素数问题不能解决, 抽空学习一下再做吧
话说这次B题做出来的人这么少不科学哈...
- 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 397B. On Corruption and Numbers
- codeforces 397B On Corruption and Numbers
- B. On Corruption and Numbers
- Codeforces 397B On Corruption and Numbers(数论)
- 【CodeForces 397B 】On Corruption and Numbers(规律)
- Codeforces Round #136 (Div. 2) B. Little Elephant and Numbers
- codefoeces B 397 - On Corruption and Numbers
- On Corruption and Numbers
- Codeforces Round #136 (Div. 2) / 221B Little Elephant and Numbers (数论)
- Codeforces Round #432 (Div. 2) D 850B Arpa and a list of numbers(gcd 枚举)
- 【简单题】【数学】-CF-397B-On Corruption and Numbers
- code forces 397B On Corruption and Numbers
- codeforces#232_div2_B On Corruption and Numbers 多元不定方程非负整数解
- codeforces 397B On Corruption and Numbers-yy-(求区间内的整数能否凑成某一整数)
- Codeforces 397B On Corruption and Numbers(数论)
- CoreAnimation-CATransform3D-1
- 在EXCEL 2010里画斜线(斜线表头)
- 进程及进程间通信IPC
- 一个人的旅行
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers
- web.xml中openEntityManagerInViewFilter的作用
- 谷歌眼镜"图片识别技术"现身
- 使用Objective-C的+(void)initialize初始化static变量
- 论文笔记---小论文
- 正则表达式
- 导入jquery就显示个红叉
- 认证码识别
- brk和sbrk及内存分配函数相关-linux+内存