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 [题目] ...
随机推荐
- Oralce学习笔记(六)
逻辑体系结构与Data file 逻辑体系结构关系图 逻辑体系结构最小单位BLOCK的研究 block能装多少行数据: drop table test_block_num purge; create ...
- Kafka学习笔记之如何永久删除Kafka的Topic
0x00 问题描述 使用kafka-topics --delete命令删除topic时并没有真正的删除,而是把topic标记为:“marked for deletion”,导致重新创建相同名称的Top ...
- 如何在ASP.NET Core Web API中使用Mini Profiler
原文如何在ASP.NET Core Web API中使用Mini Profiler 由Anuraj发表于2019年11月25日星期一阅读时间:1分钟 ASPNETCoreMiniProfiler 这篇 ...
- WPF USB设备采集开源工具介绍
最近项目需要需要试试采集电脑USB 设备信息 找到了 开源 示例 代码非常好 公共库也很友好 可能知名度太低 才4star https://github.com/vurdalakov/usbd ...
- C# 创建json传输格式的http请求
public static string PostRequestTest(string content, string url, string contentType = "applicat ...
- Win10安装IIS并配置ASP.NET 4.0
这几天新购置了电脑家用,自家电脑上上了win10+Ubuntu.解决了双系统的一些坑之后,今天准备给win10装IDE了(虽然想在Ubuntu下搞搞React/Python之类的,但我骨子里还是个.N ...
- Eclipse集成Git做团队开发:分支管理
在日常开发工作中,我们通常使用版本控制软件管理团队的源代码,常用的SVN.Git.与SVN相比,Git有分支的概念,可以从主分支创建开发分支,在开发分支测试没有问题之后,再合并到主分支上去,从而避免了 ...
- 【MySQL】MySQL高可用架构之MHA
一.关于MHA MHA(Master HA)是一款开源的MySQL的高可用程序,它为MySQL主从复制架构提供了automating master failover 功能.MHA在监控到master节 ...
- ios、安卓前端兼容性
1.日期兼容性 解决方法(请看我上一篇文章)安卓.ios时间转换成时间戳的形式 2.input框聚焦,ios出现outline或者阴影,安卓显示正常 解决方法 input:focus{outline: ...
- 6.Javascript如何处理循环的异步操作
前沿:参考ES6语法的async/await的处理机制 先上一段代码 function getMoney(){ var money=[100,200,300] for( let i=0; i<m ...