結果

問題 No.1824 門\松\列
ユーザー Nzt3Nzt3
提出日時 2022-01-28 23:58:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 163,708 KB
実行使用メモリ 19,008 KB
最終ジャッジ日時 2023-08-28 22:35:08
合計ジャッジ時間 2,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
19,000 KB
testcase_01 AC 8 ms
18,976 KB
testcase_02 AC 8 ms
18,984 KB
testcase_03 AC 10 ms
18,984 KB
testcase_04 AC 8 ms
19,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
long long ans1[1000006];
long long ans2[1000006];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ans1[3]=2,ans2[3]=2;
  for(long long i=4;i<1000006;i++){
    ans1[i]=ans1[i-1]+(i-2)*(i-1);
    ans2[i]=ans2[i-1]+(i-2)*(i-1);
  }
  int test_case;
  cin>>test_case;
  while (test_case--){
    int N;
    cin>>N;
    cout<<ans1[N]+ans2[N]<<'\n';
  }
}
 
0