結果

問題 No.2748 Strange Clock
ユーザー hiikunZhiikunZ
提出日時 2024-04-20 14:47:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,740 bytes
コンパイル時間 2,896 ms
コンパイル使用メモリ 208,232 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-04-20 14:47:37
合計ジャッジ時間 12,699 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 7 ms
6,940 KB
testcase_17 WA -
testcase_18 AC 24 ms
6,940 KB
testcase_19 WA -
testcase_20 AC 72 ms
6,940 KB
testcase_21 WA -
testcase_22 AC 222 ms
6,940 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(30,1),pow4(30,1),pow6(30,1);
    for(ll i = 1;i < 30;i++){
        pow3[i] = pow3[i - 1] * 3;
        pow4[i] = pow4[i - 1] * 4;
        pow6[i] = pow6[i - 1] * 6;
    }
    ll l = lcm(lcm(pow3[N],pow4[N]),pow6[N]);

    vector<ll> s,t;
    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];
        }
        pair<ll,ll> P = crt({p3,p4,p6},{pow3[N],pow4[N],pow6[N]});
        if(P.second != l) continue;
        //assert(p3 == b);
        //cerr << p3 << " " << p4 << " " << p6 << endl;
        //cerr << P.first << " " << P.second << endl;
        s.emplace_back(P.first);
        s.emplace_back(P.first + l);
        s.emplace_back(P.first + l + l);
        ll x = P.first - M;
        x %= l;
        if(x < 0) x += l;
        t.emplace_back(x);
    }
    sort(s.begin(),s.end());
    
    ll ans = 0;
    for(ll i = 0;i < (ll)t.size();i++){
        ll x = t[i];
        if(M > l) continue;
        auto it = lower_bound(s.begin(),s.end(),x);
        if(*it == x + M) ans++;
    }
    cout << ans << endl;
}
0