嘟嘟嘟

二分好题。

怎么二分呢?反正我是没想出来。

看了题解。

因为只有一个为奇数的点,所以对于一个位置x,求出区间[0, x]的教总和,如果为奇数,说明x取大了;否则x取小了(妙啊)。

虽然答案在int内,但是L + R可能会爆int,导致有几个点TLE了,所以还是都开long long 吧。

 #include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define rg register
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-;
const int maxn = 2e5 + ;
inline ll read()
{
ll ans = ;
char ch = getchar(), last = ' ';
while(!isdigit(ch)) {last = ch; ch = getchar();}
while(isdigit(ch)) {ans = ans * + ch - ''; ch = getchar();}
if(last == '-') ans = -ans;
return ans;
}
inline void write(ll x)
{
if(x < ) x = -x, putchar('-');
if(x >= ) write(x / );
putchar(x % + '');
} int n;
struct Node
{
ll s, e, d;
}t[maxn]; ll calc(ll x)
{
ll ret = ;
for(int i = ; i <= n; ++i)
{
if(t[i].s > x) continue;
ret += (min(x, t[i].e) - t[i].s) / t[i].d + ;
}
return ret;
} int main()
{
int T = read();
while(T--)
{
n = read(); ll Max = ;
for(int i = ; i <= n; ++i) t[i].s = read(), t[i].e = read(), t[i].d = read(), Max = max(Max, t[i].e);
ll L = , R = Max;
if(!(calc(R) & )) {puts("Poor QIN Teng:( "); continue;}
while(L < R)
{
ll mid = (L + R) >> ;
if(calc(mid) & ) R = mid;
else L = mid + ;
}
write(L), space, write(calc(L) - calc(L - )), enter;
}
return ;
}

最新文章

  1. jQuery系列:DOM操作
  2. 耿丹CS16-2班第六次作业汇总
  3. 【转载】latch: cache buffers chains
  4. Unity 碰撞检测中碰撞器与触发器的区别
  5. .net下Ueditor配置(主要讲解上传功能配置)
  6. [经验][JS]如何观察网站,进而模仿
  7. c signal
  8. bzoj 2330: [SCOI2011]糖果
  9. wpf 调用线程必须为sta 因为许多ui组件都需要
  10. 9月19号-9月21号丰宁坝上草原行 - 营销系统 - 京东内部论坛 - Powered by Discuz!
  11. win32api大全
  12. 使用Python-iGraph绘制贴吧/微博好友关系图
  13. python——序列 &amp; 集合 &amp; 映射
  14. 【Netty源码解析】NioEventLoop
  15. .Net Core跨平台应用研究-HelloDDNS(动态域名篇)
  16. 银盒子智慧餐厅硬件尺寸规格&amp;推荐机型
  17. PAT A1113 Integer Set Partition (25 分)——排序题
  18. [Windows Azure] Windows Azure SQL Database library
  19. DataTables实现rowspan思路
  20. 重构 demo篇

热门文章

  1. Linux——文件和文件夹的操作
  2. cmd笔记
  3. SpringFox
  4. BNU27935——我爱背单词——————【数组模拟】
  5. hadoop 天气案例
  6. ASP .NET SVN &amp;&amp; emmet 插件
  7. 在windows上用netsh动态配置端口转发
  8. View视图调用控制器方法
  9. gcc工作原理
  10. html相对定位绝对定位