結果

問題 No.2187 三立法和 mod 333
ユーザー US_cubeUS_cube
提出日時 2023-01-13 22:03:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,771 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 97,800 KB
実行使用メモリ 9,068 KB
最終ジャッジ日時 2023-08-26 03:48:27
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 99 ms
8,932 KB
testcase_02 AC 98 ms
8,860 KB
testcase_03 AC 98 ms
8,956 KB
testcase_04 AC 94 ms
8,960 KB
testcase_05 AC 93 ms
8,960 KB
testcase_06 AC 94 ms
8,852 KB
testcase_07 AC 98 ms
8,864 KB
testcase_08 TLE -
testcase_09 AC 95 ms
8,924 KB
testcase_10 AC 94 ms
9,064 KB
testcase_11 AC 95 ms
8,928 KB
testcase_12 AC 93 ms
8,856 KB
testcase_13 AC 92 ms
8,884 KB
testcase_14 AC 92 ms
8,860 KB
testcase_15 AC 95 ms
8,956 KB
testcase_16 AC 93 ms
8,928 KB
testcase_17 AC 94 ms
8,876 KB
testcase_18 AC 92 ms
9,064 KB
testcase_19 AC 95 ms
8,916 KB
testcase_20 AC 96 ms
9,068 KB
testcase_21 AC 94 ms
8,928 KB
testcase_22 AC 95 ms
8,884 KB
testcase_23 AC 92 ms
8,800 KB
testcase_24 AC 93 ms
8,804 KB
testcase_25 AC 94 ms
8,856 KB
testcase_26 AC 93 ms
9,056 KB
testcase_27 AC 94 ms
9,056 KB
testcase_28 AC 95 ms
8,960 KB
testcase_29 AC 94 ms
8,820 KB
testcase_30 AC 93 ms
8,932 KB
testcase_31 AC 93 ms
8,912 KB
testcase_32 AC 93 ms
9,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <climits>
#include <functional>
#include <cassert>
#include <numeric>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define per(i, n) for(int i = (n) - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
constexpr int mod = 1000000007;
using namespace std;
template<class T, class U>
bool chmax(T &a, const U &b){ return a < b ? (a = b, 1) : 0; }
template<class T, class U>
bool chmin(T &a, const U &b){ return a > b ? (a = b, 1) : 0; }
int main(){
  int a;
  cin >> a;
  vvi cnt(333, vi(4445));
  for(ll j = 1; j <= 4444; j++){
    const int v = (j*j*j) % 333;
    cnt[v][j]++;
  }
  rep(i, 333) rep(j, 4444) cnt[i][j+1] += cnt[i][j];
  ll ans = 0;
  const ll mx = 4444LL*4444*4444*4444;
  for(ll i = 1; i <= 4444; i++){
    const ll iv = i*i*i*i;
    const int iv3 = i*i*i % 333;
    for(ll j = i; iv+j*j*j*j <= mx; j++){
      const ll jv = iv+j*j*j*j;
      const int jv3 = (iv3+j*j*j) % 333;
      const int v = (333 - jv3 + a) % 333;
      const int l = sqrt(sqrt(mx - jv));
      if(l < j) continue;
      const ll num = cnt[v][l] - cnt[v][j];
      if(i == j) ans += num * 3;
      else ans += num * 6;
      if(cnt[v][j] - cnt[v][j-1] == 1){
        if(i == j) ans++;
        else ans += 3;
      }
    }
  }
  cout << ans << "\n";
}
0