#include using namespace std; using ll=long long; constexpr ll MAX_N=15; ll ipow(ll a,int n){ if(n==0)return 1ll; if(n%2)return a*ipow(a,n-1); ll ret=ipow(a,n/2); return ret*ret; } array ItoTx(ll n,int x,int N){ array ret; for(int i=0;i v,int x,int N){ ll ret=0; for(int i=N-1;i>=0;i--){ ret=ret*x+v[i]; } return ret; } namespace Lib { ll extGCD(ll a, ll b, ll &x, ll &y) { if (b == 0) { x = 1, y = 0; return a; } ll d = extGCD(b, a % b, y, x); y = y - a / b * x; return d; } ll modinv(ll a, ll m) { ll x = 0, y = 0, d = extGCD(a, m, x, y); if (d != 1) { return -1; } return x; } } // namespace Lib namespace Lib { pair crt(array r,array m) { ll ret_r = r[0], ret_m = m[0]; constexpr int n = 2; for (int i = 1; i < n; i++) { ll x = 0, y = 0, d = extGCD(ret_m, m[i], x, y); if ((ret_r - r[i]) % d != 0) { return make_pair(-1ll, -1ll); } ll tmp = x * (r[i] - ret_r) / d % (m[i] / d); ret_r += tmp * ret_m; ret_m *= m[i] / d; ret_r %= ret_m; if (ret_r < 0) ret_r += ret_m; } if (ret_r < 0) ret_r += ret_m; return make_pair(ret_r, ret_m); } } // namespace Lib int main(){ vector Ts(MAX_N,vector(0,0ll)); vector Cnts(MAX_N,vector(0,0ll)); for(ll N=1;N<=MAX_N;N++){ ll V_MAX3=ipow(3,N),V_MAX4=ipow(4,N); ll p2=ipow(2,N); unordered_map> cnt; for(int i=0;i r={i3,i4},m={V_MAX3,V_MAX4}; auto ret=Lib::crt(r,m); cnt[d].push_back(ret.first); } mapans; for(auto [i,v]:cnt){ if(v.empty())continue; sort(v.begin(),v.end()); v.push_back(v[0]+V_MAX3*V_MAX4); for(int i=1;i<(int)v.size();i++){ ans[v[i]-v[i-1]]+=1; } } for(auto i:ans){ Ts[N-1].push_back(i.first); Cnts[N-1].push_back(i.second); } } cout<<"vector> Ts={\n"; for(int i=0;i