結果
問題 |
No.2755 行列の共役類
|
ユーザー |
|
提出日時 | 2024-05-24 01:55:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 258 ms / 3,500 ms |
コード長 | 2,419 bytes |
コンパイル時間 | 4,202 ms |
コンパイル使用メモリ | 254,692 KB |
最終ジャッジ日時 | 2025-02-21 16:31:50 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 66 |
ソースコード
#include <algorithm> #include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; int B,C; vector<pair<int,int>> units[1000]; using mint = modint; /* bool judge(int x,int n_1,int y,int n_2,bool test = false){ for(int z = 1;z<=B;z++){ if(gcd(z,B)!=1) continue; if(x==1){ if(mint(n_1-n_2*z).val()==0) return true; continue; } mint bunshi = mint(n_1 - n_2*z); mint bunbo = mint(1-x); if(test){ cerr<<n_2<<' '<<z<<' '<<bunshi.val()<<" "<<bunbo.val()<<endl; } if(bunshi.val()==0) return true; int g = gcd(bunshi.val(),bunbo.val()); int tmp = bunbo.val()/g; if(gcd(tmp,B/g)==1){ return true; } } return false; } */ bool judge(int x,int n_1,int y,int n_2,bool test = false){ for(int z = 0;z<=B;z++){ if(gcd(z,B)!=1) continue; for(int n_3 = 0;n_3<B/C;n_3++){ mint tmp = mint(n_3*x+n_1- (n_2*z + n_3)); if(tmp.val()==0){ if(test){ cout<<x<<" "<<n_1<<" "<<y<<" "<<n_2<<" "<<z<<" "<<n_3<<endl; } return true; } } } return false; } void test(int x,int n_1){ for(auto &[y,n_2]:units[x]){ if(n_1==n_2) continue; if(judge(x,n_1,y,n_2,true)){ cout<<"error"<<endl; return; } } } void solve(){ int cnt = 0; for(int n_1 = 0;n_1<B/C;n_1++){ for(int x = 1;x<=B;x++){ if(gcd(x,B)!=1) continue; bool is_add = true; for(auto &[y,n_2]:units[x]){ if(judge(x,n_1,y,n_2)){ is_add = false; break; } if(judge(y,n_2,x,n_1)){ is_add = false; break; } } if(is_add){ //cerr<<x<<" "<<n_1<<endl; units[x].emplace_back(x,n_1); cnt++; } } if(cnt>100){ cout<<"100+"<<endl; return; } } cout<<cnt<<endl; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> B >> C; mint::set_mod(B/C); solve(); }