update
This commit is contained in:
parent
53381b6b21
commit
14931b0266
32
src/2/P1082.cpp
Normal file
32
src/2/P1082.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
ax%b=1
|
||||||
|
ax+by=1
|
||||||
|
*/
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
ll a,b,x,y;
|
||||||
|
|
||||||
|
ll exgcd(ll a,ll b){
|
||||||
|
if(b==0){
|
||||||
|
x=1,y=0;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
ll d = exgcd(b,a%b);
|
||||||
|
ll tmpy = y;
|
||||||
|
y=x-a/b*y;
|
||||||
|
x=tmpy;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
std::cin>>a>>b;
|
||||||
|
exgcd(a,b);
|
||||||
|
while (x<0) {
|
||||||
|
x=(x%b+b)%b;
|
||||||
|
}
|
||||||
|
std::cout<<x<<'\n';
|
||||||
|
}
|
21
src/2/P1516.cpp
Normal file
21
src/2/P1516.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ll x,y,m,n,L;
|
||||||
|
std::cin>>x>>y>>m>>n>>L;
|
||||||
|
if(x==y){
|
||||||
|
std::cout<<0<<'\n';
|
||||||
|
return 0;
|
||||||
|
}else{
|
||||||
|
if(m==n){
|
||||||
|
std::cout<<"Impossible\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
11
src/2/P2613.cpp
Normal file
11
src/2/P2613.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
ll a,b;
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
std::cin>>a>>b;
|
||||||
|
|
||||||
|
}
|
38
src/2/P5656.cpp
Normal file
38
src/2/P5656.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
ll T;
|
||||||
|
|
||||||
|
ll exgcd(ll a,ll b,ll&x,ll&y){
|
||||||
|
if(b==0){
|
||||||
|
x=1,y=0;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
ll d = exgcd(b,a%b,x,y);
|
||||||
|
ll tmpy = y;
|
||||||
|
y = x-(a/b)*y;
|
||||||
|
x=tmpy;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
// std::iostream::sync_with_stdio(false);
|
||||||
|
// std::cin.tie(nullptr),std::cout.tie(nullptr);
|
||||||
|
std::cin>>T;
|
||||||
|
|
||||||
|
while(T--){
|
||||||
|
ll a,b,c;
|
||||||
|
std::cin>>a>>b>>c;
|
||||||
|
ll x,y;
|
||||||
|
ll g{exgcd(a,b,x,y)};
|
||||||
|
if(c%g!=0){
|
||||||
|
std::cout<<-1<<'\n';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ll f = c/g;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user