結果

問題 No.2187 三立法和 mod 333
ユーザー Aging1986Aging1986
提出日時 2023-01-13 22:05:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 100 ms
コード長 2,265 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 202,780 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 03:51:05
合計ジャッジ時間 3,799 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
4,376 KB
testcase_01 AC 18 ms
4,380 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 11 ms
4,376 KB
testcase_06 AC 18 ms
4,380 KB
testcase_07 AC 36 ms
4,376 KB
testcase_08 AC 34 ms
4,380 KB
testcase_09 AC 34 ms
4,376 KB
testcase_10 AC 17 ms
4,376 KB
testcase_11 AC 20 ms
4,376 KB
testcase_12 AC 26 ms
4,380 KB
testcase_13 AC 21 ms
4,380 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 31 ms
4,376 KB
testcase_16 AC 17 ms
4,380 KB
testcase_17 AC 20 ms
4,376 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 34 ms
4,376 KB
testcase_20 AC 30 ms
4,380 KB
testcase_21 AC 35 ms
4,376 KB
testcase_22 AC 31 ms
4,380 KB
testcase_23 AC 6 ms
4,380 KB
testcase_24 AC 35 ms
4,376 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 36 ms
4,380 KB
testcase_28 AC 11 ms
4,380 KB
testcase_29 AC 31 ms
4,376 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 10 ms
4,376 KB
testcase_32 AC 29 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<vd> vvd;
#define yn(ans) printf("%s\n", (ans)?"Yes":"No");
#define YN(ans) printf("%s\n", (ans)?"YES":"NO");
template<class T> bool chmax(T &a, T b) {
	if (a >= b) return false;
	a = b; return true;
}
template<class T> bool chmin(T &a, T b) {
	if (a <= b) return false;
	a = b; return true;
}
#define FOR(i, s, e, t) for ((i) = (s); (i) < (e); (i) += (t)) 
#define REP(i, e) for (int i = 0; i < (e); ++i) 
#define REP1(i, s, e) for (int i = (s); i < (e); ++i)
#define RREP(i, e) for (int i = (e); i >= 0; --i)
#define RREP1(i, e, s) for (int i = (e); i >= (s); --i)
#define all(v) v.begin(), v.end()
#define pb push_back
#define qb pop_back
#define pf push_front
#define qf pop_front
#define maxe max_element
#define mine min_element
ll inf = 1e18;
#define DEBUG printf("%d\n", __LINE__); fflush(stdout);
template<class T> void print(vector<T> &v, bool withSize) {
	if (withSize) cout << v.size() << endl;
	REP(i, v.size()) cout << v[i] << " "; 
	cout << "\n";
}
mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

int __FAST_IO__ = []() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	std::cout.tie(0);
	return 0;
}();

int main() {
    int A;
    cin >> A;
    vvi p(333);
    REP1(i, 1, 4445) {
    	ll q = 1ll * i * i % 333 * i % 333;
    	p[q].pb(i);
    }
    
    ll tot = 1ll * 4444 * 4444 * 4444 * 4444;
    ll ans = 0;
    REP(i, 333) REP(j, 333) {
    	int t = (A + 666 - i - j) % 333;
    	for (auto a: p[i]) {
    		for (int k = 0, l = (int)p[t].size() - 1; k < p[j].size(); ++k) {
    			int b = p[j][k];
    			ll sum = 1ll * a * a * a * a + 1ll * b * b * b * b;
    			if (sum > tot) break;
    			while (l >= 0 && sum + 1ll * p[t][l] * p[t][l] * p[t][l] * p[t][l] > tot) --l;
    			if (l == -1) break;
    			ans += l + 1;
    		}
    	}
   // 	printf("%d %d %lld\n", i, j, ans);
    }
    
    printf("%lld\n", ans);
    return 0;
}
0