博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces 397B. On Corruption and Numbers
阅读量:4034 次
发布时间:2019-05-24

本文共 3465 字,大约阅读时间需要 11 分钟。

1、

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、题目:

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 ≤ 109li ≤ 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
25 2 36 4 5
Output
YesNo
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.

4、AC代码:

#include
#include
#include
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
=2*l-1) || (n>=l && n<=r) || (k*r>=n)) printf("Yes\n"); else printf("No\n"); } } return 0;}/*25 2 36 4 5*/

转载地址:http://wzcdi.baihongyu.com/

你可能感兴趣的文章
linux内核学习(4)建立正式内核的页式内存映射, 以x86 32位模式为例
查看>>
Homebrew指令集
查看>>
React Native(一):搭建开发环境、出Hello World
查看>>
React Native(二):属性、状态
查看>>
JSX使用总结
查看>>
React Native(四):布局(使用Flexbox)
查看>>
React Native(七):Android双击Back键退出应用
查看>>
Android自定义apk名称、版本号自增
查看>>
adb command not found
查看>>
Xcode 启动页面禁用和显示
查看>>
【剑指offer】q50:树中结点的最近祖先
查看>>
二叉树的非递归遍历
查看>>
【leetcode】Reorder List (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Word Break(python)
查看>>
【剑指offer】面试题26:复杂链表的复制
查看>>
【leetcode】Candy(python)
查看>>
【leetcode】Clone Graph(python)
查看>>
【leetcode】Sum Root to leaf Numbers
查看>>