結果

問題 No.1318 ABCD quadruplets
ユーザー pes_magicpes_magic
提出日時 2020-12-16 18:06:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 492 ms / 2,000 ms
コード長 1,701 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 73,852 KB
実行使用メモリ 4,648 KB
最終ジャッジ日時 2023-10-20 09:43:43
合計ジャッジ時間 7,376 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 25 ms
4,348 KB
testcase_14 AC 254 ms
4,384 KB
testcase_15 AC 24 ms
4,348 KB
testcase_16 AC 270 ms
4,348 KB
testcase_17 AC 140 ms
4,348 KB
testcase_18 AC 226 ms
4,384 KB
testcase_19 AC 202 ms
4,384 KB
testcase_20 AC 23 ms
4,348 KB
testcase_21 AC 56 ms
4,348 KB
testcase_22 AC 205 ms
4,648 KB
testcase_23 AC 484 ms
4,648 KB
testcase_24 AC 453 ms
4,648 KB
testcase_25 AC 241 ms
4,648 KB
testcase_26 AC 219 ms
4,648 KB
testcase_27 AC 379 ms
4,648 KB
testcase_28 AC 249 ms
4,648 KB
testcase_29 AC 262 ms
4,648 KB
testcase_30 AC 492 ms
4,648 KB
testcase_31 AC 243 ms
4,648 KB
testcase_32 AC 481 ms
4,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N, M; cin >> N >> M;
    vector<long long> res(N+1, 0);
    for(int a=0;a<=M;a++){
        long long s0 = a*a;
        for(int b=a;b<=M;b++){
            long long s1 = s0 + (a+b)*b;
            if(s1 > N) break;
            for(int c=b;c<=M;c++){
                long long s2 = s1 + (a+b+c)*c;
                if(s2 > N) break;
                for(int d=c;d<=M;d++){
                    long long s3 = s2 + (a+b+c+d)*d;
                    if(s3 > N) break;
                    if(a == b){
                        if(b == c){
                            if(c == d){
                                res[s3]++;
                            } else {
                                res[s3] += 4;
                            }
                        } else {
                            if(c == d){
                                res[s3] += 6;
                            } else {
                                res[s3] += 12;
                            }
                        }
                    } else {
                        if(b == c){
                            if(c == d){
                                res[s3] += 4;
                            } else {
                                res[s3] += 12;
                            }
                        } else {
                            if(c == d){
                                res[s3] += 12;
                            } else {
                                res[s3] += 24;
                            }
                        }
                    }
                }
            }
        }
    }
    for(auto& t : res) cout << t << endl;
}
0