結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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>
#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;

std::pair<ll,ll> bisearch(ll l,ll r,std::function<bool(ll)> f){
    while((l+1)<r){
        ll m=(l+r)/2;
        if(f(m)) r=m;
        else l=m;
    }
    return std::make_pair(l,r);
}
ll SQRT4(ll n){if(n==1) return 1;return bisearch(0,n,[n](ll x){return x>((n/x)/x)/x;}).first;}


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

int main(){
    int a;cin>>a;
    for(ll z = 1; z <= 4444; z++)
    {
        ll z3 = z*z*z;
        cnt[z][z3%mod]++;
        memcpy(&cnt[z+1][0], &cnt[z][0], mod);
        p3[z] = z3;
        p4[z] = z3*z;
    }
    int ans = 0;
    for(int x = 1; x < 4444; x++)
    {
        for(int y = 1; y < 4444; y++)
        {
            ll zmax = p4[4444] - p4[x] - p4[y];
            if(zmax <= 0) break;
            zmax = SQRT4(zmax);
            int z3 = (a + mod - (p3[x] + p3[y])%mod)%mod;
            int c = cnt[zmax][z3];
            //if(c) cerr << x << " " << y << " " << zmax << " " << z3 << " " << c << endl;
            ans += c;
        }
        //cerr << x << "\n";
    }
    cout << ans << endl;
}
0