codeforces 397B. On Corruption and Numbers
来源:互联网 发布:吃播催吐知乎 编辑:程序博客网 时间:2024/06/06 03:24
1、http://codeforces.com/problemset/problem/397/B
2、题目大意:
用l-r区间的面额,组成金额n,看能否能组成
假设f是用l最接近n的值,我们假设能够找到f和n的差值,那么就能组成这样的n的面额,一开始以为只要存在一个值在区间中等于l+x(x为f和n的差值),其实这样想是不对的,可以用最多k个次r值组成这个差值x,网上代码给出k*r>=n就可以,实际上是在证k*l<=n<=(k+1)*l,这样n就存在
就理解这么多,待续
3、题目:
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 thanni, 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 thanri. The rector also does not carry coins of denomination less thanli 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 denominationx 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 numbersni, 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 fromli tori 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 nextt 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.
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){ int t; int n,l,r; scanf("%d",&t); while(t--) { scanf("%d%d%d",&n,&l,&r); if(n<l && n<r) printf("No\n"); else { int k=n/l; if((r>=2*l-1) || (n>=l && n<=r) || (k*r>=n)) printf("Yes\n"); else printf("No\n"); } } return 0;}/*25 2 36 4 5*/
- codeforces 397B. On Corruption and Numbers
- codeforces 397B On Corruption and Numbers
- Codeforces 397B On Corruption and Numbers(数论)
- 【CodeForces 397B 】On Corruption and Numbers(规律)
- codefoeces B 397 - On Corruption and Numbers
- 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
- 【简单题】【数学】-CF-397B-On Corruption and Numbers
- code forces 397B On Corruption and Numbers
- codeforces 397B On Corruption and Numbers-yy-(求区间内的整数能否凑成某一整数)
- 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(l-r)
- codeforces#232_div2_B On Corruption and Numbers 多元不定方程非负整数解
- Codeforces_397B_On Corruption and Numbers(数论)
- codeforces 221B Little Elephant and Numbers
- VIM编写shell脚本程序之个人体会 持续更新中。。。
- asterisk1.8 Makefile分析 (2)
- android开发中应用程序未安装解决办法
- 【数据结构】二叉查找树【续】之非递归遍历
- DOMINO 访问 SQL 数据库 (转载)
- codeforces 397B. On Corruption and Numbers
- ldconfig
- adb remount adb shell
- XML和JSON两种数据交换格式的比较
- 数字三角形II
- LKM的概念
- 使用C# 完美实现多语言版本Windows应用程序
- ubuntu13.04下载 编译android 4.0 (二) 内涵常见错误
- 关于Jenkins Master空间不足导致Master Node一直Offline的解决方案