結果

問題 No.2187 三立法和 mod 333
ユーザー lddlinanlddlinan
提出日時 2023-03-15 22:57:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 100 ms
コード長 1,328 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 89,044 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 12:36:51
合計ジャッジ時間 3,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
4,348 KB
testcase_01 AC 12 ms
4,348 KB
testcase_02 AC 6 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 6 ms
4,348 KB
testcase_06 AC 12 ms
4,348 KB
testcase_07 AC 27 ms
4,348 KB
testcase_08 AC 26 ms
4,348 KB
testcase_09 AC 27 ms
4,348 KB
testcase_10 AC 12 ms
4,348 KB
testcase_11 AC 14 ms
4,348 KB
testcase_12 AC 20 ms
4,348 KB
testcase_13 AC 15 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 22 ms
4,348 KB
testcase_16 AC 12 ms
4,348 KB
testcase_17 AC 14 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 27 ms
4,348 KB
testcase_20 AC 22 ms
4,348 KB
testcase_21 AC 27 ms
4,348 KB
testcase_22 AC 22 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 26 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 26 ms
4,348 KB
testcase_28 AC 7 ms
4,348 KB
testcase_29 AC 22 ms
4,348 KB
testcase_30 AC 5 ms
4,348 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 22 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;


vector<LL> vs[333];
int ks[128];
int main() {
    int n, i, c=0, f1, f2,f3, j, a;
    scanf("%d", &a);
    LL v, vv, mv, r, dv, x;
    mv=4444; mv*=4444; mv*=4444; mv*=4444;
    for (i=1; i<4444; i++) {
        v=i; v*=i; v*=i;
        vv=v*i;
        v%=333;
        vs[v].push_back(vv);
    }
    for (i=0; i<333; i++) if (!vs[i].empty()) {
        // sort(vs[i].begin(), vs[i].end());
        ks[c++]=i;
    }
    r=0;
    for (i=0; i<c; i++) {
        f1=ks[i];
        for (j=0; j<c; j++) {
            f2=ks[j];
            f3=(a-f1-f2+666)%333;
            if (vs[f3].empty()) continue;
            for (auto v1 : vs[f1]) {
                x=vs[f3].size();
                for (auto v2: vs[f2]) {
                    if (v1+v2>=mv) break;
                    dv=mv-v1-v2;
                    while(x&&vs[f3][x-1]>dv) x--;
                    if (x==0) break;
                    r+=x;
                }
            }
        }
    }
    printf("%lld\n", r);
    return 0;
}
0