当前位置:网站首页>2022 Henan Mengxin League game (3): Henan University
2022 Henan Mengxin League game (3): Henan University
2022-07-26 17:59:00 【AC automatic mail】
J- Magic number
Ideas :
First, analyze the congruence of two numbers :a ≡ b ( mod x )
We know :(a - b) / x It must be an integer ( namely 、x | (a - b) ), So just make x by (a - b) The factor of that will do
Secondly, consider the case of three number congruences : a ≡ b ≡ c ( mod x )
Equivalent to three congruences being established at the same time :a ≡ b ( mod x ) && b ≡ c ( mod x ) && c ≡ a ( mod x )
Can be launched ( x | (a - b) && x | (b - c) && x | (c - a) )
Three equations hold at the same time , namely 、x by gcd(a-b, b-c, c-a) The factor of ( Is the factor of the greatest common divisor , Then the three equations hold at the same time )
The code is as follows :
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(nullptr); cout.tie(nullptr)
#define x first
#define y second
#define int long long
using namespace std;
typedef pair<int, int> PII;
const int N = 2e5 + 10, M = 1010;
const int mod = 1e9 + 7;
int T;
int n, m, sum;
PII a[N];
void check(int a, int b, int c)
{
vector<int> v;
int x = __gcd(abs(a - b), __gcd(abs(b - c), abs(c - a)));
for(int i = 1; i <= x / i; i ++ )
{
if(x % i == 0)
{
v.push_back(i);
if(x / i != i) v.push_back(x / i);
}
}
sort(v.begin(), v.end());
for(auto it : v)
cout << it << " ";
cout << endl;
return;
}
void solve()
{
int a, b, c;
cin >> a >> b >> c;
if(a == b && b == c)
{
cout << "-1" << endl;
return;
}
else check(a, b, c);
}
signed main()
{
cin >> T;
while(T -- )
solve();
return 0;
}
边栏推荐
- GAN (Generative Adversarial Network,GAN)生成式对抗网络
- 10、 Implementation of parameter modification of parameter server
- 【集训Day3】section
- Overview of the agenda of the keynote speech of apachecon Asia, an international celebrity vs a local open source star
- 【模板】线段树 1
- [static code quality analysis tool] Shanghai daoning brings you sonarource/sonarqube download, trial and tutorial
- The database uses PSQL and JDBC to connect remotely and disconnect automatically from time to time
- 《敏捷宣言》四大价值观,十二大原则
- Linux安装mysql8.0.29详细教程
- 【集训Day1】 Dwarves line up
猜你喜欢

重磅!《2022中国开源发展蓝皮书》正式发布

AI zhetianchuan DL regression and classification

Ascend target detection and recognition - customize your own AI application

web项目文件简单上传和下载

解决哈希冲突的几种方式
![[day3] reconstruction of roads](/img/52/cc8b81bccbf4aa02ec82fedfb49d19.png)
[day3] reconstruction of roads

2022年的PMP考试大纲是什么?

来吧开发者!不只为了 20 万奖金,试试用最好的“积木”来一场头脑风暴吧!

AI zhetianchuan ml integrated learning

AI zhetianchuan ml unsupervised learning
随机推荐
来吧开发者!不只为了 20 万奖金,试试用最好的“积木”来一场头脑风暴吧!
二层管理型交换机如何设置IP
JS 函数作用域 变量声明提升 作用域链 不加var的变量,是全局变量
Mondriaans‘s Dream(状态压缩DP)
Interview with celebrities | open source is a double-edged sword for security -- Wei Jianfan, author of the Chinese translation of cathedral and market
【集训Day1】 Dwarves line up
Cross Site Request Forgery (CSRF)
就这一次!详细聊聊分布式系统的那些技术方案
Sequential storage structure of linear table -- sequential table
The user experience center of Analysys Qianfan bank was established to help upgrade the user experience of the banking industry
Week 16 OJ practice 1 calculates the day of the year
Ascend目标检测与识别-定制自己的AI应用
10、 Implementation of parameter modification of parameter server
国际象棋机器人夹断7岁男孩手指,原因是「棋手违反安全规则」?
8、 Topic communication: topic substitution and monitoring
Click hijacking attack
Machine learning by Li Hongyi 2. Regression
数据库使用psql及jdbc进行远程连接,不定时自动断开的解决办法
Asemi rectifier bridge kbpc2510, kbpc2510 parameters, kbpc2510 specifications
VS Code 格式化后 自动让函数名后有空格