$des$

https://loj.ac/problem/10215

$sol$

exgcd检查

$code$

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cstdio> using namespace std; #define gc getchar()
inline int read() {
int x = ; char c = gc;
while(c < '' || c > '') c = gc;
while(c >= '' && c <= '') x = x * + c - '', c = gc;
return x;
} #define LL long long const int N = ; LL C[N], P[N], L[N];
int n;
int M = 1e6; LL Exgcd(LL a, LL b, LL &x, LL &y) {
if(b == ) {
x = , y = ; return a;
}
LL gg = Exgcd(b, a % b, x, y);
LL tmp = x;
x = y, y = tmp - a / b * y;
return gg;
} bool Solve(LL k) {
for(int i = ; i <= n; i ++) {
for(int j = i + ; j <= n; j ++) {
LL c1 = C[i], c2 = C[j], p1 = P[i], p2 = P[j], x, y;
LL b = p1 - p2, d = c2 - c1;
if(b < ) b = -b, d = -d;
LL g = Exgcd(b, k, x, y);
if(d % g) continue;
x *= (d / g);
LL r = k / g;
while(x < ) x += r;
x %= r;
if(x <= min(L[i], L[j])) return ;
}
}
return ;
} int main() {
n = read();
LL Max = ;
for(int i = ; i <= n; i ++)
C[i] = read(), P[i] = read(), L[i] = read(), Max = max(Max, C[i]);
int a;
for(a = Max; a <= M; a ++) {
if(Solve(1ll * a)) {
cout << a; return ;
}
} return ;
}

59: loj #10215的更多相关文章

  1. LOJ.6060.[2017山东一轮集训Day1/SDWC2018Day1]Set(线性基)

    LOJ BZOJ 明明做过一道(最初思路)比较类似的题啊,怎么还是一点思路没有. 记所有元素的异或和为\(s\),那么\(x_1+x_2=x_1+x_1\ ^{\wedge}s\). \(s\)是确定 ...

  2. LOJ 3119: 洛谷 P5400: 「CTS2019 | CTSC2019」随机立方体

    题目传送门:LOJ #3119. 题意简述: 题目说的很清楚了. 题解: 记恰好有 \(i\) 个极大的数的方案数为 \(\mathrm{cnt}[i]\),则答案为 \(\displaystyle\ ...

  3. Loj#143-[模板]质数判定【Miller-Rabin】

    正题 题目链接:https://loj.ac/p/143 题目大意 给出一个数\(p\),让你判定是否为质数. 解题思路 \(Miller-Rabin\)是一种基于费马小定理和二次探测定理的具有较高正 ...

  4. 编写高质量代码:改善Java程序的151个建议(第4章:字符串___建议56~59)

    建议56:自由选择字符串拼接方法 对一个字符串拼接有三种方法:加号.concat方法及StringBuilder(或StringBuffer ,由于StringBuffer的方法与StringBuil ...

  5. C#得到某月最后一天晚上23:59:59和某月第一天00:00:00

    项目需求: 某学校订单截止操作时间的上一个月最后一天晚上23:59:59 为止所有支付的订单统计: 代码: /// <summary> /// 通过学校和截止时间得到订单 /// < ...

  6. 重新想象 Windows 8 Store Apps (59) - 锁屏

    [源码下载] 重新想象 Windows 8 Store Apps (59) - 锁屏 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 锁屏 登录锁屏,获取当前程序的锁 ...

  7. Loj 1003–Drunk(拓扑排序)

    1003 - Drunk PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB One of my fr ...

  8. svn://59.46.115.123:13690/IOS/trunk/02.DevelopLib/04.Coding/uuridesharing

    svn://59.46.115.123:13690/IOS/trunk/02.DevelopLib/04.Coding/uuridesharing

  9. 59. 总结篇:数组中N(n=1,2,3)个只出现一次的数字[find N numbers which appear only once in array]

    [本文链接] http://www.cnblogs.com/hellogiser/p/find-n-numbers-which-appear-only-once-in-array.html [题目] ...

随机推荐

  1. 如何在ASP.NET Core Web API中使用Mini Profiler

    原文如何在ASP.NET Core Web API中使用Mini Profiler 由Anuraj发表于2019年11月25日星期一阅读时间:1分钟 ASPNETCoreMiniProfiler 这篇 ...

  2. TServerSocket组件

    主要作为服务器端的套接字管理器使用.它封装了服务器端的套接字.在打开套接字后,服务器端就处于监听状态,在接收到其它机器的连接请求后,与客户端建立连接,创建一个新的套接字,用于和客户端互传数据,此时TS ...

  3. axios捕获401 赋值token

    //捕获401 // http request 拦截器 axios.interceptors.request.use( config => { const token = localStorag ...

  4. Python网络编程、爬虫之requests模块使用

    一.python操作网络,也就是打开一个网站,或者请求一个http接口,使用urllib模块. urllib模块是一个标准模块,直接import urllib即可,在python3里面只有urllib ...

  5. Django(二)模板

    一.模板概念 1.Django通过模板动态生成html 2.模板的加载位置 模板一般建立在templates文件夹中,全局路径的设置在settings.py中 ​ DIRS:决定了整个项目的模板路径的 ...

  6. Java自学-接口与继承 多态

    Java的多态 操作符的多态 +可以作为算数运算,也可以作为字符串连接 类的多态 父类引用指向子类对象 示例 1 : 操作符的多态 同一个操作符在不同情境下,具备不同的作用 如果+号两侧都是整型,那么 ...

  7. Django:RestFramework之-------路由

    11.路由 路由设置: url(r'^(?P<version>[v1|v2]+)/vview\.(?P<format>\w+)$', views.VView.as_view({ ...

  8. CentOS 7 - 安装Python 3

    Enable Software Collections (SCL) Software Collections, also known as SCL is a community project tha ...

  9. consul:健康检查

    官方文档:https://www.consul.io/docs/agent/checks.html consul提供的健康检查有以下几种: 1.script+interval 2.http+inter ...

  10. 安装socketio出现module 'importlib._bootstrap' has no attribute 'SourceFileLoader' 错误

    安装socketio出现module 'importlib._bootstrap' has no attribute 'SourceFileLoader' 错误 执行: pip install --u ...