codeforces 397B On Corruption and Numbers-yy-(求区间内的整数能否凑成某一整数)
来源:互联网 发布:php网络编程 编辑:程序博客网 时间:2024/05/16 23:45
题意:求一段连续的整数能否凑成某一个整数n。区间内的整数使用次数不限
分析:这题的题面的硬币凑钱,所以我刚开始以为是dp,无限背包,但是发现不是背包问题,但我还是认为是个dp,于是写了一个转移方程,似乎是对的,准备写代码的时候才发现用dp的话,数组根本不可能开那么大 10^9,所以我确定不是dp,根据经验觉得应该是个yy题,于是开始手动找规律,发现:只要n在区间 k[l,r]里面,就能用区间内的整数凑成n,换句话说就是能找到一个合法的k即可,即:n/r <= n/l ,注意一点是:当n%r==0时左端点直接用n/r,否则要用n/r+1,这里要注意,在很多题都有这个小细节。
代码:
#include<iostream>using namespace std;int main(){int t;int n,l,r;cin>>t;while(t--){cin>>n>>l>>r;int a=n/l;int b;if(n%r==0) b=n/r;else b=n/r+1;if(b<=a) cout<<"Yes"<<endl;else cout<<"No"<<endl;}}
0 0
- codeforces 397B On Corruption and Numbers-yy-(求区间内的整数能否凑成某一整数)
- codeforces 397B. On Corruption and Numbers
- codeforces 397B 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(规律)
- codeforces#232_div2_B 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
- On Corruption and Numbers
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers 题解
- On Corruption and Numbers(l-r)
- Leetcode 201 Bitwise AND of Numbers Range 区间内整数按位与
- 【LeetCode】006 Bitwise AND of Numbers Range 区间内整数按位与
- 如何用Curl 来post xml 数据
- Flash手游《孤胆英雄》独立开发者专访
- PHP设计模式漫谈之调解者模式
- Xcode 新建项目时ViewController.m默认的viewDidLoad消失
- shell自动打包ipa
- codeforces 397B On Corruption and Numbers-yy-(求区间内的整数能否凑成某一整数)
- __cplusplus解析
- JAVA RMI远程方法调用简单实例
- java中yyyy-MM-dd HH:mm:ss类型转换成long类型
- ASP.NET MVC4中调用WEB API的四个方法
- IOS中使得图片模糊的效果的方法
- OpenGL中的多重采样
- uva 196 spreadsheet
- Android Context简介