結果
問題 |
No.2187 三立法和 mod 333
|
ユーザー |
![]() |
提出日時 | 2023-01-14 16:03:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,373 bytes |
コンパイル時間 | 1,748 ms |
コンパイル使用メモリ | 194,572 KB |
最終ジャッジ日時 | 2025-02-10 03:30:23 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 33 |
ソースコード
#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; }