結果

問題 No.2187 三立法和 mod 333
ユーザー otamay6otamay6
提出日時 2023-01-14 17:01:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,585 bytes
コンパイル時間 2,952 ms
コンパイル使用メモリ 213,708 KB
実行使用メモリ 15,288 KB
最終ジャッジ日時 2023-08-26 22:45:51
合計ジャッジ時間 6,758 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 77 ms
15,096 KB
testcase_02 AC 45 ms
15,000 KB
testcase_03 AC 27 ms
15,020 KB
testcase_04 AC 27 ms
15,028 KB
testcase_05 AC 46 ms
15,288 KB
testcase_06 AC 75 ms
15,000 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 76 ms
14,988 KB
testcase_11 AC 81 ms
14,996 KB
testcase_12 TLE -
testcase_13 AC 81 ms
15,052 KB
testcase_14 AC 46 ms
14,976 KB
testcase_15 TLE -
testcase_16 AC 76 ms
14,988 KB
testcase_17 AC 82 ms
15,112 KB
testcase_18 AC 27 ms
15,028 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 28 ms
14,980 KB
testcase_24 TLE -
testcase_25 AC 27 ms
14,992 KB
testcase_26 AC 28 ms
15,100 KB
testcase_27 TLE -
testcase_28 AC 46 ms
14,972 KB
testcase_29 TLE -
testcase_30 AC 45 ms
15,024 KB
testcase_31 AC 44 ms
15,048 KB
testcase_32 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

constexpr int mod = 333;
ll cnt[4445][mod]; // iまでにz^3がj mod 333であるような数
ll p4[4445];
ll p3[4445];
ll p3m[4445];

int main(){
    int a;cin>>a;
    for(ll z = 1; z <= 4444; z++)
    {
        ll z3 = z*z*z;
        REP(i, mod) cnt[z][i] = cnt[z-1][i];
        cnt[z][z3%mod]++;
        p3[z] = z3;
        p3m[z] = p3[z] % mod;
        p4[z] = z3*z;
    }
    int ans = 0;
    #if 1
    for(int x = 1; x < 4444; x++)
    {
        int ans2 = 0;
        int prev_zmax = 4444;
        for(int y = x; y < 4444; y++)
        {
            int z3 = (a + 2 * mod - (p3m[x] + p3m[y])) % mod;
            if(cnt[4443][z3] <= 0) continue;
            ll zmax = p4[4444] - p4[x] - p4[y];
            if(zmax <= 0) break;
            int left = 1;
            while(prev_zmax > left + 1)
            {
                int mid = (left + prev_zmax) >> 1;
                ((p4[mid] <= zmax) ? left : prev_zmax) = mid;
                //cerr << left << " " << prev_zmax << endl;
            }
            int c = cnt[left][z3];
            if(y==x) ans += c;
            else ans2 += c;
        }
        ans += 2 * ans2;
        //cerr << x << "\n";
    }
    struct Q{
        int z3;

    };

    #endif
    cout << ans << endl;
}
0