結果

問題 No.1318 ABCD quadruplets
ユーザー otoshigootoshigo
提出日時 2023-02-22 14:05:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 390 ms / 2,000 ms
コード長 1,268 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 77,184 KB
実行使用メモリ 4,440 KB
最終ジャッジ日時 2023-09-29 22:12:31
合計ジャッジ時間 6,231 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 101 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 151 ms
4,376 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 92 ms
4,376 KB
testcase_19 AC 36 ms
4,376 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 16 ms
4,380 KB
testcase_22 AC 11 ms
4,380 KB
testcase_23 AC 338 ms
4,380 KB
testcase_24 AC 313 ms
4,376 KB
testcase_25 AC 52 ms
4,376 KB
testcase_26 AC 31 ms
4,440 KB
testcase_27 AC 211 ms
4,380 KB
testcase_28 AC 60 ms
4,380 KB
testcase_29 AC 78 ms
4,376 KB
testcase_30 AC 390 ms
4,380 KB
testcase_31 AC 58 ms
4,384 KB
testcase_32 AC 356 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int F(int a,int b,int c,int d){
    if(a==b&&b==c&&c==d)return 1;
    else if((a==b&&b==c)||(b==c&&c==d))return 4;
    else if(a==b&&c==d)return 6;
    if(a==b||b==c||c==d)return 12;
    else return 24;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin>>N>>M;
    vector<ll>ans(N+1);
    for(int a=0;a<=M;a++){
        int e=a*a;
        for(int b=a;b<=M;b++){
            int f=e+b*b;
            if(f>2*N)break;
            for(int c=b;c<=M;c++){
                int g=f+c*c;
                if(g>2*N)break;
                for(int d=c;d<=M;d++){
                    int h=g+d*d+(a+b+c+d)*(a+b+c+d);
                    if(h<=2*N){
                        ans[h/2]+=F(a,b,c,d);
                    }else break;
                }
            }
        }
    }
    rep(i,N+1)cout<<ans[i]<<"\n";
}
0