結果

問題 No.276 連続する整数の和(1)
ユーザー Rp7rfRp7rf
提出日時 2015-09-04 23:03:18
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 546 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 61,664 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 06:18:01
合計ジャッジ時間 4,769 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 142 ms
4,384 KB
testcase_04 AC 141 ms
4,380 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main(void){
  int n;
  cin>>n;
  unsigned long long sum[3]={0};
  
  bool ans = true;
  
  for(int i = 1 ; i <= n ; i ++){
    sum[0] += i;
    sum[1] += 1 + i;
    sum[2] += 2 + i;
    //   for(int j = 0 ; j < 10 ; j ++)cout<<sum[j]<<" " ;
    //cout<<endl;
  }
  
  unsigned long long gcd =  __gcd(sum[0],sum[1]);
  for(int i = 2 ;i < 3 ; i ++){
    unsigned long long  num = sum[i];
    //cout<<sum[i]<<endl;
    gcd = __gcd(gcd,num);
  }
  cout<<gcd<<endl;
 
}
0