59: loj #10215
$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的更多相关文章
- LOJ.6060.[2017山东一轮集训Day1/SDWC2018Day1]Set(线性基)
LOJ BZOJ 明明做过一道(最初思路)比较类似的题啊,怎么还是一点思路没有. 记所有元素的异或和为\(s\),那么\(x_1+x_2=x_1+x_1\ ^{\wedge}s\). \(s\)是确定 ...
- LOJ 3119: 洛谷 P5400: 「CTS2019 | CTSC2019」随机立方体
题目传送门:LOJ #3119. 题意简述: 题目说的很清楚了. 题解: 记恰好有 \(i\) 个极大的数的方案数为 \(\mathrm{cnt}[i]\),则答案为 \(\displaystyle\ ...
- Loj#143-[模板]质数判定【Miller-Rabin】
正题 题目链接:https://loj.ac/p/143 题目大意 给出一个数\(p\),让你判定是否为质数. 解题思路 \(Miller-Rabin\)是一种基于费马小定理和二次探测定理的具有较高正 ...
- 编写高质量代码:改善Java程序的151个建议(第4章:字符串___建议56~59)
建议56:自由选择字符串拼接方法 对一个字符串拼接有三种方法:加号.concat方法及StringBuilder(或StringBuffer ,由于StringBuffer的方法与StringBuil ...
- C#得到某月最后一天晚上23:59:59和某月第一天00:00:00
项目需求: 某学校订单截止操作时间的上一个月最后一天晚上23:59:59 为止所有支付的订单统计: 代码: /// <summary> /// 通过学校和截止时间得到订单 /// < ...
- 重新想象 Windows 8 Store Apps (59) - 锁屏
[源码下载] 重新想象 Windows 8 Store Apps (59) - 锁屏 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 锁屏 登录锁屏,获取当前程序的锁 ...
- Loj 1003–Drunk(拓扑排序)
1003 - Drunk PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB One of my fr ...
- 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
- 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 [题目] ...
随机推荐
- WPF USB设备采集开源工具介绍
最近项目需要需要试试采集电脑USB 设备信息 找到了 开源 示例 代码非常好 公共库也很友好 可能知名度太低 才4star https://github.com/vurdalakov/usbd ...
- 解决Spring Boot 从1.x升级到 2.x 后 单点登陆(SSO)问题
解决Spring Boot 从1.x升级到 2.x 后 单点登陆(SSO)问题 在学习Spring Cloud 时,遇到了授权服务oauth 相关内容时,总是一知半解,因此决定先把Spring S ...
- tomcat启动Publishing failed with multiple errors
转自:https://blog.csdn.net/leisurelen/article/details/46940441 新安装一个tomcat插件.启动的时候就弹错误框.但tomcat还能使用. P ...
- Kafka Streams开发入门(4)
背景 上一篇演示了filter操作算子的用法.今天展示一下如何根据不同的条件谓词(Predicate)将一个消息流实时地进行分流,划分成多个新的消息流,即所谓的流split.有的时候我们想要对消息流中 ...
- Python的矩阵传播机制&矩阵运算
Python的矩阵传播机制(Broadcasting) 最近在学习神经网络.我们知道在深度学习中经常要操作各种矩阵(matrix).回想一下,我们在操作数组(list)的时候,经常习惯于用for循环( ...
- 3.kettle-定时执行任务
kettle定时任务可以 用两种方法. 第一种如下,但这种缺点也很明显,就是该job窗口不能关闭.(重复时间含义问题截图来自https://www.cnblogs.com/biehongli/p/10 ...
- Linux service进程管理
Linux进程基本介绍: 1)在Linux中,每个执行的程序(代码)都称为一个进程.每一个进程都分配一个ID号. 2)每一个进程,都对应一个父进程,而这个父进程可以复制多个子进程.例如www服务器. ...
- maven nexus 私服搭建 Windows版
准备工作 已安装jdk,并配置好了环境变量 已安装maven,并配置好了环境变量 下载Nexus Repository OSS:https://www.sonatype.com/download-os ...
- Linux必知必会--sed
致沅弟:至于当大事,全在明强二字. --<曾国藩家书> 参考资料:https://man.linuxde.net/sed https://www.jianshu.com/p/047cd ...
- SpringCloud2.0 Hystrix Feign 基于Feign实现断路器 基础教程(七)
1.启动[服务中心]集群,工程名:springcloud-eureka-server 参考 SpringCloud2.0 Eureka Server 服务中心 基础教程(二) 2.启动[服务提供者]集 ...