結果

問題 No.2187 三立法和 mod 333
ユーザー t98slidert98slider
提出日時 2023-01-13 23:10:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,607 bytes
コンパイル時間 1,685 ms
コンパイル使用メモリ 173,744 KB
実行使用メモリ 208,876 KB
最終ジャッジ日時 2023-08-26 04:53:53
合計ジャッジ時間 4,559 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A;
    cin >> A;
    vector<vector<ll>> tb(333), c(333), tb2(333);
    vector<ll> pow4(4445), pow3(4445);
    for(ll i = 1; i <= 4444; i++){
        pow4[i] = i * i * i * i;
        pow3[i] = (i * i * i) % 333;
    }
    ll v = pow4[4444];
    for(ll i = 1; i <= 4444; i++){
        c[pow3[i]].push_back(pow4[i]);
        for(ll j = 1; j <= 4444; j++){
            ll v2 = pow4[i] + pow4[j];
            if(v2 > v) break;
            ll v3 = pow3[i] + pow3[j];
            if(v3 >= 333)v3 -= 333;
            tb[v3].push_back(v2);
            if(i == j){
                tb2[v3].push_back(v2);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 333; i++){
        sort(tb[i].begin(), tb[i].end());
        for(int i2 = 0; i2 < 333; i2++){
            if((i + i2) % 333 != A)continue;
            for(int j = int(tb[i].size()) - 1, k = 0; j >= 0; j--){
                while(k < c[i2].size() && c[i2][k] + tb[i][j] <= v)k++;
                ans += k;
            }
        }
    }
    /*for(int i = 0; i < 333; i++){
        for(int i2 = 0; i2 < 333; i2++){
            if((i + i2) % 333 != A)continue;
            for(int j = int(tb2[i].size()) - 1, k = 0; j >= 0; j--){
                while(k < c[i2].size() && c[i2][k] + tb2[i][j] <= v)k++;
                ans -= k;
            }
        }
    }
    for(int i = 1; i <= 4444; i++){
        if((3 * pow3[i]) % 333 != A)continue;
        ans += (3 * pow4[i] <= v);
    }*/
    cout << ans << '\n';
}
0