code forces 397B On Corruption and Numbers
来源:互联网 发布:淘宝未发货自动退款 编辑:程序博客网 时间:2024/06/05 11:58
code forces 397B On Corruption and Numbers
题目链接:http://codeforces.com/problemset/problem/397/B
题目大意:给校长行贿以获得录取资格,校长只收n元钱,多了少了都不行,行贿着手里有l元~r元这些币值的硬币(每种无数),问此次行贿能否成功。
题目分析:(根本不是背包)要分情况讨论。如果n<l,就代表最小币值比所要钱数大,肯定不行;如果l<=n<=r,说明所要钱数恰好在已有币值里面,一定能行,剩下的情况需要进一步讨论,如果r>2*l说明n/2一定可以被l~r覆盖;n/l得到一个数,这个数乘以l所得的值必小于等于n,如果这个数乘以r所得的值大于等于n,说明l~r的币值组合必能覆盖n,一定可以。
code:
#include<stdio.h>int main(){ int n,l,r,flag,t;//贪污数、币值下限、币值上限 scanf("%d",&t); while(t--) {scanf("%d%d%d",&n,&l,&r); if(n<l)flag=0; else if(r>2*l||n>=l&&n<=r||n/l*r>=n)flag=1; else flag=0; if(flag)printf("Yes\n"); else printf("No\n");} return 0;}PS:精华部分全是抄的……最后这两种略微复杂,且缺一不可,为什么这样就能过,现在还处于不明觉厉阶段。
0 0
- code forces 397B On Corruption and Numbers
- codeforces 397B. On Corruption and Numbers
- codefoeces B 397 - On Corruption and Numbers
- codeforces 397B On Corruption and Numbers
- B. On Corruption and Numbers
- Codeforces 397B On Corruption and Numbers(数论)
- 【简单题】【数学】-CF-397B-On Corruption and Numbers
- 【CodeForces 397B 】On Corruption and Numbers(规律)
- 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-yy-(求区间内的整数能否凑成某一整数)
- On Corruption and Numbers(l-r)
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers 题解
- Codeforces Round #232 (Div. 2) B.On Corruption and Numbers(整数拆分)
- code forces 401B Sereja and Contests
- Code Forces 313B Ilya and Queries
- Code forces 699B
- 4. 《算法概论》思维导图
- 当一个对象实例作为一个参数被传递到方法中时,参数的值就是对该对象的引用。对象的内容可以在被调用的方法中改变,但对象的引用是永远不会改变的.
- 安装Windows 7和Linux(Ubuntu)双系统手记
- 001_014 Python 改变多行文本字符串的缩进
- 从没静下心来
- code forces 397B On Corruption and Numbers
- Linux的10个经典彩蛋
- WebService基础
- c++ oc
- Android_Service组件详解
- 关于nextLine()和next()的使用,区别
- Gas Station
- openURL的使用方法:
- 在grep和sed中用到的简单正则表达式