【链接】http://www.ifrog.cc/acm/problem/1161


【题意】


在这里写题意

【题解】


首先x<l肯定无解;
然后,肯定是要选其中的一些数字的.
而且这些数字肯定是大于等于l的.
则我们尽可能多的先选一些l
即x/l个l;
然后剩下rest=x/l-l就用cnt个数字[0..r-l]来填;
且cnt <= x/l;
表示把其中的一些l扩大一点,变成大于l的数字.
也即判断(x/l)*(r-l)是不是大于等于rest的
很巧妙的方法。。
最后整理一下会发现就是判断
设temp = x/l
r*temp>=x
是不是成立的。
把r除到右边去,向上取整判断一下就好

【错的次数】


5

【反思】


先入为主地以为是一道不可做的数论题了

【代码】

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <set>
#include <cstdlib>
#include <cmath>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
#define sz(x) ((int) x.size()) typedef pair<int, int> pii;
typedef pair<LL, LL> pll; //mt19937 myrand(time(0));
//int get_rand(int n) { return myrand() % n + 1; }
const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 110; LL x, l, r; int main() {
//Open();
//Close();
int T;
ri(T);
while (T--) {
rl(x), rl(l), rl(r);
if (x < l) {
puts("TAT");
}
else {
LL temp = x / l;
LL rest = x - l*temp;
//(r - l)*temp >= x-l*temp
//r*temp-l*temp>=x-l*temp
//r*temp>=x
//r*temp>=x
//temp>=x/r
LL temp2 = ceil(1.0 * x / r);
if (temp >= temp2)
puts("QWQ");
else
puts("TAT");
}
}
return 0;
}

最新文章

  1. WEB 基础知识(一)
  2. js中二维数组的初始化
  3. LIS最长上升子序列O(n^2)与O(nlogn)的算法
  4. javascrpt插入html中中文字符乱码问题记录
  5. mysql中字段类型转换排序
  6. file_get_contents抓取远程URL内容
  7. js-2
  8. 烂泥:虚拟化KVM安装与配置
  9. Linux关机命令
  10. Java 数组操作
  11. UICollectionView 简单应用和实际操作
  12. JDBC之修改数据
  13. struts2自定义拦截器与cookie整合实现用户免重复登入
  14. mysql left用法
  15. 解决ERROR 2006 (HY000): MySQL server has gone away
  16. Python with ASP
  17. hadoop三个配置文件的参数含义说明core-site.xml,hdfs-site.xml,mapred-site.xml
  18. 由一次自建库迁移到阿里云RDS引发的性能问题。
  19. android 2048游戏、kotlin应用、跑马灯、动画源码
  20. TensorFlow tutorial

热门文章

  1. python学习二,字符串常用操作
  2. 使用scatter画散点图
  3. 【2017 Multi-University Training Contest - Team 1 1011】KazaQ's Socks
  4. Springboot集成mybatis通用Mapper与分页插件PageHelper
  5. BZOJ——T 3732: Network
  6. [Python] Manage Dependencies with Python Virtual Environments
  7. 第8章7节《MonkeyRunner源代码剖析》MonkeyRunner启动执行过程-小结
  8. jdbc的数据库驱动类DriverManager.getConnection()详解
  9. 程序中为什么会使用while(0)
  10. 【hdu 3987】Harry Potter and the Forbidden Forest