結果

問題 No.2187 三立法和 mod 333
ユーザー umimelumimel
提出日時 2023-01-13 22:28:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,571 bytes
コンパイル時間 1,715 ms
コンパイル使用メモリ 170,060 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-26 04:12:44
合計ジャッジ時間 27,377 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll a;
    cin >> a;

    vector<vector<ll>> b(333LL);
    rep(i, 333LL){
        rep(z, 333LL){
            if((z*z*z)%333LL == i) b[i].pb(z);
        }
    }

    ll ans = 0LL;
    ll P = 4444LL*4444LL*4444LL*4444LL;
    for(ll x=1; x*x*x*x <= P; x++){
        for(ll y=1; y*y*y*y <= P-x*x*x*x; y++){
            ll c = P - x*x*x*x - y*y*y*y;
            ll r = a - (x*x*x)%333LL - (y*y*y)%333LL + 333LL + 333LL;
            r %= 333LL;
            ll lw = -1;
            ll hi = 4444;
            ll mid;
            while(hi - lw > 1){
                mid = (lw + hi)/2;

                if(mid*mid*mid*mid <= c) lw = mid;
                else hi = mid;
            }
            if(lw == -1) continue;
            for(ll z : b[r]){
                if(z==0){
                    ll n = lw/333LL;
                    ll m = lw%333LL;
                    ans += n;
                }else{
                    ll n = lw/333LL;
                    ll m = lw%333LL;
                    ans += n;
                    if(z <= m) ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
}
0