結果

問題 No.1318 ABCD quadruplets
コンテスト
ユーザー pes_magic
提出日時 2020-12-16 18:06:37
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 1,701 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 428 ms
コンパイル使用メモリ 92,396 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-16 01:07:59
合計ジャッジ時間 4,677 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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