题目链接:Codeforces 397B On Corruption and Numbers
题目大意:给出n,l,r,表示用l~r中间任何数的面值若干个组成n,可以输出Yes,不可以输出No。
解题思路:一开想到dp的一道题,当l*k ≤r*(k-1)的时候,l*(k-1)往上就可以全部可行,但是超时了。
起始可以换个简单的想法, 找到最接近n的f,f为l的倍数,即l*k ≤ n,然后判断,如果r*k≥n的话,即为可行。
#include <stdio.h> #include <string.h> #include <iostream> using namespace std; typedef long long ll; ll n, l, r; bool judge () { ll k = n / l; return r * k >= n; } int main () { int cas; scanf("%d", &cas); while (cas--) { cin >> n >> l >> r; printf("%s\n", judge() ? "Yes" : "No"); } return 0; }
Codeforces 397B On Corruption and Numbers(数论),布布扣,bubuko.com
Codeforces 397B On Corruption and Numbers(数论)
原文:http://blog.csdn.net/keshuai19940722/article/details/20046277