博客
关于我
Mail.Ru Cup 2018 Round 2 C. Lucky Days(扩展欧几里得)
阅读量:387 次
发布时间:2019-03-05

本文共 529 字,大约阅读时间需要 1 分钟。

#include 
using namespace std;typedef long long ll;int main() { ll l1, r1, t1, l2, r2, t2; scanf("%lld %lld %lld", &l1, &r1, &t1); scanf("%lld %lld %lld", &l2, &r2, &t2); ll d = __gcd(t1, t2); if (abs(l2 - l1) % d == 0) { printf("%lld\n", min(r1 - l1 + 1, r2 - l2 + 1)); return 0; } ll d1 = (l2 - l1) % d, d2 = (l1 - l2) % d; if (d1 < 0) d1 += d; if (d2 < 0) d2 += d; printf("%lld\n", max(1LL * 0, max(min(r1 - l1 - d1 + 1, r2 - l2 + 1), min(r1 - l1 + 1, r2 - l2 - d2 + 1))));}

转载地址:http://qqewz.baihongyu.com/

你可能感兴趣的文章
PHP下curl用法分析
查看>>
php与web服务器关系
查看>>
redis事务操作
查看>>
php中0,空,null和false的区别
查看>>
PHP中array_merge和array相加的区别分析
查看>>
PHP中Closure::bindTo的用法分析
查看>>
php中curl得使用
查看>>
PHP中curl特性
查看>>
PHP中date时间不对
查看>>
PHP中dirname(__FILE__)的意思
查看>>
PHP中extract()函数的妙用
查看>>
PHP中fileinfo的作用以及怎么开启fileinfo
查看>>
PHP中file_get_contents如何带上cookies
查看>>
PHP中header的作用
查看>>
PHP中implode()和explode()
查看>>
PHP中ob系列函数讲解(浏览器缓存技术)
查看>>
PHP中serialize和json序列化与反序列化的区别
查看>>
Redis事务处理
查看>>
php中传值与传引用的区别是什么
查看>>
php中使用ajax进行前后端json数据交互
查看>>