olp_61 Ước số
Xem dạng PDF
Gửi bài giải
Điểm:
10,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
1G
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài

Bình luận
include <bits/stdc++.h>
using namespace std;
define ll long long
ll m;
struct matrix { ll f[2][2]; };
matrix mul(matrix a, matrix b) { matrix c; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { c.f[i][j] = 0; for (int k = 0; k < 2; k++) { // ep sang int128 de nhan khong bi tran so c.f[i][j] = (c.f[i][j] + (int128)a.f[i][k] * b.f[k][j]) % m; } } } return c; }
matrix power(matrix a, ll n) { matrix res; res.f[0][0] = 1; res.f[0][1] = 0; res.f[1][0] = 0; res.f[1][1] = 1; while (n > 0) { if (n % 2 == 1) res = mul(res, a); a = mul(a, a); n /= 2; } return res; }
ll gcd(ll a, ll b) { while (b != 0) { ll r = a % b; a = b; b = r; } return a; }
int main() { iosbase::syncwith_stdio(false); cin.tie(0);
}
include <bits/stdc++.h>
using namespace std;
define ll long long
ll m;
struct matrix { ll f[2][2]; };
matrix mul(matrix a, matrix b) { matrix c; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { c.f[i][j] = 0; for (int k = 0; k < 2; k++) { // ep sang int128 de nhan khong bi tran so c.f[i][j] = (c.f[i][j] + (int128)a.f[i][k] * b.f[k][j]) % m; } } } return c; }
matrix power(matrix a, ll n) { matrix res; res.f[0][0] = 1; res.f[0][1] = 0; res.f[1][0] = 0; res.f[1][1] = 1; while (n > 0) { if (n % 2 == 1) res = mul(res, a); a = mul(a, a); n /= 2; } return res; }
ll gcd(ll a, ll b) { while (b != 0) { ll r = a % b; a = b; b = r; } return a; }
int main() { iosbase::syncwith_stdio(false); cin.tie(0);
}