結果
問題 | No.2755 行列の共役類 |
ユーザー | NAMIDAIRO |
提出日時 | 2024-05-11 13:32:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 7,257 bytes |
コンパイル時間 | 1,505 ms |
コンパイル使用メモリ | 127,668 KB |
実行使用メモリ | 14,016 KB |
最終ジャッジ日時 | 2024-05-11 13:32:38 |
合計ジャッジ時間 | 17,304 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 38 ms
6,944 KB |
testcase_04 | AC | 55 ms
6,940 KB |
testcase_05 | AC | 29 ms
6,940 KB |
testcase_06 | AC | 15 ms
6,944 KB |
testcase_07 | AC | 53 ms
6,940 KB |
testcase_08 | AC | 27 ms
6,944 KB |
testcase_09 | AC | 18 ms
6,940 KB |
testcase_10 | AC | 12 ms
6,940 KB |
testcase_11 | AC | 9 ms
6,940 KB |
testcase_12 | AC | 4 ms
6,940 KB |
testcase_13 | AC | 74 ms
6,940 KB |
testcase_14 | AC | 20 ms
6,940 KB |
testcase_15 | AC | 15 ms
6,944 KB |
testcase_16 | AC | 9 ms
6,944 KB |
testcase_17 | AC | 122 ms
6,944 KB |
testcase_18 | AC | 39 ms
6,940 KB |
testcase_19 | AC | 14 ms
6,944 KB |
testcase_20 | AC | 188 ms
6,940 KB |
testcase_21 | AC | 70 ms
6,944 KB |
testcase_22 | AC | 19 ms
6,948 KB |
testcase_23 | AC | 22 ms
6,944 KB |
testcase_24 | AC | 24 ms
6,944 KB |
testcase_25 | AC | 16 ms
6,940 KB |
testcase_26 | AC | 13 ms
6,944 KB |
testcase_27 | AC | 236 ms
6,944 KB |
testcase_28 | AC | 120 ms
6,944 KB |
testcase_29 | AC | 31 ms
6,944 KB |
testcase_30 | AC | 162 ms
6,944 KB |
testcase_31 | AC | 129 ms
6,944 KB |
testcase_32 | AC | 60 ms
6,944 KB |
testcase_33 | AC | 17 ms
6,940 KB |
testcase_34 | AC | 25 ms
6,944 KB |
testcase_35 | AC | 14 ms
6,940 KB |
testcase_36 | AC | 7 ms
6,940 KB |
testcase_37 | AC | 20 ms
6,940 KB |
testcase_38 | AC | 52 ms
6,940 KB |
testcase_39 | AC | 80 ms
6,940 KB |
testcase_40 | AC | 74 ms
6,944 KB |
testcase_41 | AC | 118 ms
6,940 KB |
testcase_42 | AC | 273 ms
6,944 KB |
testcase_43 | AC | 126 ms
6,944 KB |
testcase_44 | AC | 27 ms
6,944 KB |
testcase_45 | AC | 26 ms
6,944 KB |
testcase_46 | AC | 9 ms
6,944 KB |
testcase_47 | AC | 14 ms
6,940 KB |
testcase_48 | AC | 138 ms
6,940 KB |
testcase_49 | AC | 6 ms
6,944 KB |
testcase_50 | AC | 22 ms
6,944 KB |
testcase_51 | AC | 6 ms
6,940 KB |
testcase_52 | AC | 6 ms
6,944 KB |
testcase_53 | TLE | - |
testcase_54 | AC | 1,842 ms
6,944 KB |
testcase_55 | AC | 1,253 ms
6,940 KB |
testcase_56 | TLE | - |
testcase_57 | -- | - |
testcase_58 | -- | - |
testcase_59 | -- | - |
testcase_60 | -- | - |
testcase_61 | -- | - |
testcase_62 | -- | - |
testcase_63 | -- | - |
testcase_64 | -- | - |
testcase_65 | -- | - |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <queue> #include <set> #include <random> #include <iomanip> #include <string> #include <cmath> #include <complex> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) template<class T> using vi = vector<T>; template<class T> using vii = vector<vi<T>>; template<class T> using viii = vector<vii<T>>; template<class T> using viiii = vector<viii<T>>; using P = pair<ll, int>; void chmin(ll & x, ll y) { x = min(x, y); } void chmax(ll& x, ll y) { x = max(x, y); } struct mint { const long long mod = 998244353; long long x; mint(long long x_ = 0) : x((x_% mod + mod) % mod) {} mint& operator+=(const mint& other) { x += other.x; if (x >= mod) x -= mod; return *this; } mint& operator-=(const mint& other) { x -= other.x; if (x < 0) x += mod; return *this; } mint& operator*=(const mint& other) { x *= other.x; x %= mod; return *this; } mint& operator+=(const long long n) { return *this += mint(n); } mint& operator-=(const long long n) { return *this -= mint(n); } mint& operator*=(const long long n) { return *this *= mint(n); } mint& operator=(const mint& other) { x = other.x; return *this; } mint& operator=(const long long n) { x = n % mod; return *this; } bool operator==(const mint& other) const { return x == other.x; } bool operator!=(const mint& other) const { return x != other.x; } mint operator-() const { mint res(mod - x); return res; } mint operator+(const mint& other) const { mint res(x); return res += other; } mint operator-(const mint& other) const { mint res(x); return res -= other; } mint operator*(const mint& other) const { mint res(x); return res *= other; } mint operator+(const long long n) const { mint res(x); mint other(n); return res += other; } mint operator-(const long long n) const { mint res(x); mint other(n); return res -= other; } mint operator*(const long long n) const { mint res(x); mint other(n); return res *= other; } mint pow(long long n) const { if (n == 0) return mint(1); mint res = pow(n / 2); res *= res; if (n % 2) res *= *this; return res; } mint inv() const { return pow(mod - 2); } mint& operator/=(const mint& other) { *this *= other.inv(); return *this; } mint operator/(const mint& other) const { mint res(x); return res /= other; } }; struct combination { vector<mint> fact, ifact; combination(int m) :fact(m + 1), ifact(m + 1) { fact[0] = 1; for (int i = 1; i <= m; i++) fact[i] = fact[i - 1] * mint(i); ifact[m] = fact[m].inv(); for (int i = m; i >= 1; i--) ifact[i - 1] = ifact[i] * mint(i); } mint operator()(int n, int k) {//for n<=m, calc nck if (k < 0 || k > n) return mint(0); return fact[n] * ifact[k] * ifact[n - k]; } }; template<class T> struct NTT { const int divlim = 23; //when mod is 998244353 vector<mint> root, invroot; const mint primitive = 3; NTT() : root(divlim + 1), invroot(divlim + 1) { root[divlim] = primitive.pow((primitive.mod - 1) >> divlim); invroot[divlim] = root[divlim].inv(); for (int i = divlim - 1; i >= 0; i--) { root[i] = root[i + 1] * root[i + 1]; invroot[i] = invroot[i + 1] * invroot[i + 1]; } } void dft(vector<mint>& d, const int log, const bool inv = false) { int n = (int)d.size(); if (n == 1 || log == 0) return; vector<mint> d0, d1; for (int i = 0; i < n / 2; i++) { d0.push_back(d[2 * i]); d1.push_back(d[2 * i + 1]); } dft(d0, log - 1, inv); dft(d1, log - 1, inv); mint pow = 1, z = (inv ? invroot[log] : root[log]); for (int i = 0; i < n / 2; i++) { d[i] = d0[i] + d1[i] * pow; pow *= z; } for (int i = n / 2; i < n; i++) { d[i] = d0[i - n / 2] + d1[i - n / 2] * pow; pow *= z; } return; } void idft(vector<mint>& d, const int log) { dft(d, log, true); return; } vector<mint> convolution(vector<T>& f, vector<T>& g) { int n = 1, log = 0, lenf = (int)f.size(), leng = (int)g.size(); while (n < lenf + leng) { n <<= 1; log++; } vector<mint> df(n), dg(n); for (int i = 0; i < lenf; i++) df[i] = f[i]; for (int i = 0; i < leng; i++) dg[i] = g[i]; dft(df, log); dft(dg, log); for (int i = 0; i < n; i++) df[i] *= dg[i]; idft(df, log); mint ninv = mint(n).inv(); for (int i = 0; i < n; i++) df[i] *= ninv; return df; } }; int gcd(int& x, int y) { return y ? gcd(y, x % y) : x; } int main() { int b, c; cin >> b >> c; int ans = 0; int bb = b * b; vi<bool> check(bb + 1); auto mat = [&](vii<int>& x, vii<int>& y, vii<int> &res) { rep(i, 2) rep(j, 2) rep(k, 2) { res[i][k] += x[i][j] * y[j][k]; } return; }; auto inv = [&](vii<int>& x, vii<int>& res) { res[0][0] = x[1][1]; res[0][1] = -x[0][1]; res[1][0] = -x[1][0]; res[1][1] = x[0][0]; }; auto det = [&](vii<int>& x) { return x[0][0] * x[1][1] - x[0][1] * x[1][0]; }; auto modpow = [&](auto modpow, int x, int n)->auto { if (n == 1) return x; int res = modpow(modpow, x, n / 2); res *= res; res %= b; if (n & 1) res *= x; res %= b; return res; }; vi<int> modinv(b + 1); //for (int i = 1; i < b; i++) modinv[i] = modpow(modpow, i, b - 2); for (int i = 1; i < b; i++) { if (gcd(b, i) > 1) continue; rep(j, b) { if (gcd(b, j) > 1) continue; if ((i * j) % b == 1) { modinv[i] = j; break; } } } for(int i = 0; i < bb; i += c) { if (check[i]) continue; int x = i / b, y = i % b; if (y % c != 0 || gcd(b, x) > 1) continue; ans++; if (ans > 100) { cout << "100+" << endl; return 0; } vii<int> P = { {x, y}, {0, 1} }; for (int j = 0; j < bb; j += c) { //if (check[j]) continue; int xr = j / b, yr = j % b; if (yr % c != 0 || gcd(b, xr) > 1) continue; vii<int> R = { {xr, yr}, {0, 1} }; vii<int> Ri(2, vi<int>(2)); inv(R, Ri); int detR = xr; int xq = x, yq = ((x - 1) * yr + y) * modinv[xr]; yq %= b; int num = xq * b + yq; check[num] = true; } } cout << ans << endl; return 0; }