device:

用最小公倍数的知识或是画网格模拟转移,神仙们也可以找规律。然后就变成区间覆盖了。

忘记特殊情况了,大众分→Ag

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long i64;
const int N=2e6+;
const i64 INF=1e18+; struct sgm{
i64 x,y;
bool operator<(const sgm a)const{
return x<a.x||x==a.x&&y<a.y;
}
}t[N];
int cnt; i64 gcd(i64 n,i64 m){
while(n%m){
swap(n,m);
m%=n;
}
return m;
} int main()
{
int n,i;
i64 a,b,x,y;
scanf("%d%lld%lld",&n,&a,&b);
i64 l;
if(a/gcd(a,b+)>=(double)INF/b)
l=INF;
else
l=a/gcd(a,b+)*b;
for(i=;i<=n;i++){
scanf("%lld%lld",&x,&y);
if(y-x+>=l){  //我怎么就这么睿智(
printf("%lld",l);
return ;
}
else{
x%=l,
y%=l;
if(x<=y){
++cnt,
t[cnt].x=x,
t[cnt].y=y;
}
else{
++cnt,
t[cnt].x=,
t[cnt].y=y;
++cnt,
t[cnt].x=x,
t[cnt].y=l-;
}
}
}
sort(t+,t+cnt+);
x=t[].x,
y=t[].y;
i64 s=;
for(i=;i<=cnt;i++)
if(t[i].x>y){
s+=y-x+;
x=t[i].x,
y=t[i].y;
}
else
y=max(y,t[i].y);
s+=y-x+;
printf("%lld",s);
return ;
}

bridges:

分块

lamps:

不会做咕咕咕

最新文章

  1. mysql数据备份
  2. centOS升级python3.5
  3. Javascript中构造函数与new命令2
  4. PHP获取图片宽度高度、大小尺寸、图片类型、用于布局的img属性
  5. Python学习笔记10
  6. 11039 - Building designing
  7. Spring.Net.FrameworkV3.0 版本发布了,感谢大家的支持
  8. web classpath 路径说明
  9. git命令常见问题总结
  10. 内存恶鬼drawRect
  11. BestCoder HDU 5750 Dertouzos
  12. 去除 waring Method &#39;CreateNew&#39; hides virtual method of base type &#39;TCustomForm&#39;
  13. python无私有成员变量
  14. iOS安全攻防
  15. WPF Canvas小例子
  16. c++内存管理错误记录
  17. MySQL之终端(Terminal)管理MySQL(转)
  18. python实现PKCS5Padding
  19. 当Azure里的虚拟机网卡被禁用
  20. 故障定位之查找附近点GeoHash研讨

热门文章

  1. Vue学习笔记【27】——Vue路由(设置路由)
  2. bzoj 3251
  3. Windows Xp Sp3官方简体中文版(原版) 纯净安装版 百度网盘下载
  4. iconfont字体图标的使用方法
  5. BZOJ 3622: 已经没有什么好害怕的了(二项式反演)
  6. vue2 — vuex状态管理
  7. 探索Redis设计与实现14:Redis事务浅析与ACID特性介绍
  8. tomcat部署项目遇到的问题
  9. Django基础篇(二)与mysql配合使用
  10. 4.Grafana展示监控数据