結果
| 問題 |
No.2748 Strange Clock
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-20 15:19:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,975 bytes |
| コンパイル時間 | 3,115 ms |
| コンパイル使用メモリ | 215,544 KB |
| 最終ジャッジ日時 | 2025-02-21 06:43:00 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | AC * 24 TLE * 1 -- * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include<atcoder/math>
using namespace atcoder;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
constexpr ll MAX = 2000000000000000000;
constexpr ld PI = 3.14159265358979;
constexpr ll MOD = 0;//2024948111;
ld dotorad(ld K){ return PI * K / 180.0; }
ld radtodo(ld K){ return K * 180.0 / PI; }
mt19937 mt;
void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); }
int main(){
ll N,M;
cin >> N >> M;
vector<ll> pow3(60,1),pow4(60,1),pow6(60,1),pow2(60,1);
for(ll i = 1;i < 60;i++){
pow2[i] = pow2[i - 1] * 2;
pow3[i] = pow3[i - 1] * 3;
pow4[i] = pow4[i - 1] * 4;
pow6[i] = pow6[i - 1] * 6;
}
ll l = pow2[N * 2] * pow3[N];
map<ll,vector<ll>> A,B;
vector<ll> Z;
for(ll bb = 0;bb < pow3[N];bb++){
ll c = bb;
ll p3 = 0,p4 = 0,p6 = 0;
for(ll i = 0;i < N;i++){
ll x = c % 3;
c /= 3;
p3 += x * pow3[i];
p4 += x * pow4[i];
p6 += x * pow6[i];
}
tuple<ll,ll> P = crt({p3,p4},{pow3[N],pow4[N]});
ll x = get<0>(P),m = get<1>(P);
ll zurasi = p6 - x;
zurasi %= pow6[N];
if(zurasi < 0) zurasi += pow6[N];
Z.emplace_back(zurasi);
//assert(m == l);
A[zurasi].emplace_back(x);
A[zurasi].emplace_back(x + l);
A[zurasi].emplace_back(x + l + l);
x -= M;
x %= l;
if(x < 0) x += l;
B[zurasi].emplace_back(x);
}
sort(Z.begin(),Z.end());
Z.erase(unique(Z.begin(),Z.end()),Z.end());
ll ans = 0;
for(ll z : Z){
vector<ll> a = A[z],b = B[z];
sort(a.begin(),a.end());
sort(b.begin(),b.end());
for(ll i = 0;i < b.size();i++){
ll x = b[i];
auto it = lower_bound(a.begin(),a.end(),x);
if(*it == x + M) ans++;
}
}
cout << ans << endl;
}