因为码风的修改是时候要有个收集板子的地方了。
欧拉函数
int phi[N],prime[N],tot,pri[N];
void init (int n) {
phi[1] = 1;
for (int i = 2; i <= n; i++) {
if (prime[i] == 0) {
pri[++tot] = i;
phi[i] = i - 1;
}
for (int j = 1; j <= tot && i * pri[j] <= n; j++) {
prime[i*pri[j]] = 1;
phi[i*pri[j]] = phi[i] * phi[pri[j]];
if (i % pri[j] == 0) {
phi[i*pri[j]] = phi[i] * pri[j];
break;
}
}
}
}或 搭配线性筛
int phi(int x){
int ans = x;
for (int i = 1; i <= tot; i++)
if (x % prime[i] == 0)
ans = ans / v[i] * (v[i] - 1);
return ans;
}线性筛
void init (int n) {
for (int i = 2; i <= n; i++) {
if (pri[i] == 0)
prime[++tot] = i;
for (int j = 1; j <= tot && i * prime[j] <= n; j++) {
pri[i*prime[j]] = 1;
if (i % prime[j] == 0)
break;
}
}
}exgcd
#include<bits/stdc++.h>
#define int long long
#define db double
using namespace std;
const int N=1e5+5;
int a,b,c,x,y;
int excit (int a, int b, int &x, int &y) {
if (b == 0) {
x=1;
y=0;
return a;
}
int gc = excit(b, a % b, x, y), t=x;
x = y, y = t - (a / b) * y;
return gc;
}
void work () {
cin >> a >> b >> c;
int gc = excit(a, b, x, y);
if (c % gc != 0) {
cout << -1 << '\n';
return ;
}
x = c / gc * x, y = c / gc * y;
int dx = b / gc, dy = a / gc;
if (x < 0) {
int k = ceil((1.0 - x) / dx);
x += dx * k, y -= dy * k;
}
else {
int k = (x - 1) / dx;
x -= dx * k, y += dy * k;
}
if (y > 0)
cout << (y - 1) / dy + 1 << ' ' << x << ' ' << (y - 1) % dy + 1 << ' ' << x + (y - 1) / dy * dx << ' ' << y << '\n';
else
cout << x << ' ' << y + dy * (int)ceil((1.0 - y) / dy) << '\n';
return ;
}signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T;
cin >> T;
while (T--)
work();
return 0;
}