結果
問題 |
No.3186 Big Order
|
ユーザー |
|
提出日時 | 2025-06-20 21:40:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,588 bytes |
コンパイル時間 | 6,846 ms |
コンパイル使用メモリ | 333,508 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-20 21:40:22 |
合計ジャッジ時間 | 10,064 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | RE * 34 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; typedef long long int ll; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<vvvl> vvvvl; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<vvb> vvvb; typedef vector<vvvb> vvvvb; typedef pair<ll,ll> pl; typedef pair<ll,pl> ppl; typedef pair<ll,ppl> pppl; typedef pair<ll,pppl> pppppl; #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(a) begin(a),end(a) #define sz(a) (int)(a).size() #define F first #define S second #define bs(A,x) binary_search(all(A),x) #define lb(A,x) (ll)(lower_bound(all(A),x)-A.begin()) #define ub(A,x) (ll)(upper_bound(all(A),x)-A.begin()) #define cou(A,x) (ll)(upper_bound(all(A),x)-lower_bound(all(A),x)) template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>; template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;} template<class T>bool chmin(T&a,T b){if(b<a){a=b;return 1;}return 0;} //* using mint=modint998244353; const ll mod=998244353; //*/ /* using mint=modint1000000007; const ll mod=1000000007; //*/ //using mint=modint; //* typedef vector<mint> vm; typedef vector<vm> vvm; typedef vector<vvm> vvvm; typedef vector<vvvm> vvvvm; ostream&operator<<(ostream&os,mint a){os<<a.val();return os;} istream&operator>>(istream&is,mint&a){int x;is>>x;a=mint(x);return is;} //*/ template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>p){os<<p.F<<" "<<p.S;return os;} template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.F>>p.S;return is;} template<typename T>ostream&operator<<(ostream&os,vector<T>v){rep(i,0,sz(v))os<<v[i]<<(i+1!=sz(v)?" ":"");return os;} template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;} ll pow_mod(ll _a,ll b,ll m){ __int128 res=1,a=_a%m; while(b){ if(b%2)res=res*a%m; a=a*a%m;b/=2; } return res; } bool is_prime(ll N){ if(N==1)return false; if(N==2)return true; if(N%2==0)return false; ll s=0,d=N-1; while(d%2==0)d/=2,s++; vector<long long>A={2,325,9375,28178,450775,9780504,1795265022}; for(auto a:A){ long long g=__gcd(a,N); if(g>1){ if(g!=N)return false; continue; } __int128 x=pow_mod(a,d,N); if(x!=1&&x!=N-1){ bool ok=0; for(int i=0;i<s-1;i++){ x=x*x%N; if(x==N-1){ok=1;break;} if(x==1)break; } if(!ok)return false; } } return true; } ll div(ll n){ if(n%2==0)return 2; ll d=0; while(++d){ __int128 x=0,y=0; while(1){ x=(x*x+d)%n; y=(y*y+d)%n; y=(y*y+d)%n; ll g=__gcd((ll)(x-y),n); if(g==n)break; if(g>1)return g; } } return -1; } vector<ll>factorize(ll N){ if(N==1)return {}; vector<ll>f,c={N}; while(!c.empty()){ auto m=c.back(); c.erase(c.end()-1); if(is_prime(m)){ f.emplace_back(m); continue; } ll d=div(m); if(is_prime(m/d))f.emplace_back(m/d); else c.emplace_back(m/d); if(is_prime(d))f.emplace_back(d); else c.emplace_back(d); } sort(f.begin(),f.end()); return f; } int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ll _;cin>>_; while(_--){ ll A,B,C;cin>>A>>B>>C; auto fa=factorize(A); auto fc=factorize(C); map<ll,ll>a,c; for(auto p:fa)a[p]+=B; for(auto p:fc)c[p]++; ll ans=1e18; for(auto[p,v]:c)chmin(ans,a[p]/v); cout<<ans%mod<<endl; } return 0; }