当前位置:网站首页>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;
}
边栏推荐
- 有一说一,阿里P7的薪资待遇是真的香
- [training Day1] Dwaves line up
- 深度学习实验:Softmax实现手写数字识别
- Zhaoqi science and technology innovation overseas high-level talent introduction platform, entrepreneurship event Roadshow
- URL jump vulnerability
- 【集训Day1】 Dwarves line up
- [Oumi reading club] talk about the creator economy in the meta universe: infinite dimension
- The chess robot broke the finger of a 7-year-old boy because "the chess player violated safety rules"?
- Click hijacking attack
- [cloud native] IVX low code development was introduced into Tencent map and previewed online
猜你喜欢

2、 Topic communication principle, code implementation

【集训Day3】Reconstruction of roads

Come on developer! Not only for the 200000 bonus, try the best "building blocks" for a brainstorming
![[template] segment tree 1](/img/60/9f73d00223c8878ffd8513b3b9adf7.jpg)
[template] segment tree 1

树形dp问题

Hosts this file has been set to read-only solution

Hardware development and market industry

Just this time! Talk about the technical solutions of distributed system in detail

一文详解吞吐量、QPS、TPS、并发数等高并发指标

【欧米读书会】谈谈元宇宙中的创作者经济:无限次元
随机推荐
AI遮天传 DL-多层感知机
就这一次!详细聊聊分布式系统的那些技术方案
openssl
The Agile Manifesto has four values and twelve principles
跨站脚本攻击(XSS)
CentOS installs docker and MySQL and redis environments
Basic select statement
How to assemble a registry?
【集训Day1】Spy dispatch
[static code quality analysis tool] Shanghai daoning brings you sonarource/sonarqube download, trial and tutorial
uni-app
Spark unified memory partition
VIM多行操作
Quartz trigger rule
Tianyi cloud web application firewall (edge cloud version) supports the detection and interception of Apache spark shell command injection vulnerabilities
【元宇宙欧米说】剖析 Web3 风险挑战,构筑 Web3 生态安全
After vs code is formatted, the function name will be automatically followed by a space
Heavy! The 2022 China open source development blue book was officially released
We were tossed all night by a Kong performance bug
Is it really safe and reliable to exempt five in case of opening an account in a stock company