当前位置:网站首页>2022 Henan Mengxin League game (3): Henan University J - magic number
2022 Henan Mengxin League game (3): Henan University J - magic number
2022-07-26 04:31:00 【WA_ automata】
J - Magic number
solution : If the three numbers are equal , The result of the remainder of any number is the same , Output − 1 −1 −1. If you don't want to wait , Think of any number can be written x × y + w x×y +w x×y+w, do a − b = ( x 1 − x 2 ) × y a−b = (x1 −x2)×y a−b=(x1−x2)×y, this when a , b a, b a,b Yes x 1 − x 2 x1 − x2 x1−x2, y The remainder result is the same , If it is a , b , c a, b, c a,b,c Then take g c d ( a b s ( a − b ) , a b s ( b − c ) , a b s ( a − c ) ) gcd(abs(a − b), abs(b − c), abs(a − c)) gcd(abs(a−b),abs(b−c),abs(a−c)) Then output all the quality factors .
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;cin>>T;
while(T--)
{
int a,b,c;cin>>a>>b>>c;
if(a==b&&a==c) cout<<"-1"<<endl;
else
{
int d1=abs(a-b),d2=abs(b-c);
int t=__gcd(d1,d2);
set<int> s;
for(int i=1;i*i<=t;i++)
if(t%i==0)
{
s.insert(i);
if(i*i!=t) s.insert(t/i);
}
for(auto &p:s)
cout<<p<<" ";
cout<<endl;
}
}
return 0;
}
边栏推荐
猜你喜欢

机器学习之信用卡欺诈检测

青少年创客教育的创意设计原理

TIA botu WinCC Pro controls the display and hiding of layers through scripts

Postman imports curl, exports curl, and exports corresponding language codes

Getting started with mongodb Basics

Integrated architecture of performance and cost: modular architecture

MySQL - multi table query - Cartesian product sum, correct multi table query, equivalent connection and unequal connection, inner connection and outer connection

Steam science education endows classroom teaching with creativity

Acwing刷题

Unable to find sygwin.s file during vscode debugging
随机推荐
AWS Support Plan
Chapter 3 how to use sourcetree to submit code
1. Excel的IF函数
Use of anonymous functions
SwiftUI一日速成
QT compilation error sorting and remote module Download
Getting started with mongodb Basics
2、 Internationally renowned project HelloWorld
Function knowledge points
UE4 keyboard control switch light
Scroll view pull-down refresh and pull-up load (bottom)
十、拦截器
5、 Domain objects share data
A series of problems about the number of DP paths
RTSP/Onvif协议视频平台EasyNVR服务一键升级功能的使用教程
Solution: runtimeerror: expected object of scalar type int but got scalar type double
View and modify the number of database connections
Sangi diagram of machine learning (for user behavior analysis)
自动化测试框架该如何搭建?
MapReduce中分区数与ReduceTask个数关系比较