結果

問題 No.276 連続する整数の和(1)
ユーザー Rp7rfRp7rf
提出日時 2015-09-04 23:01:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 695 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 62,456 KB
実行使用メモリ 7,724 KB
最終ジャッジ日時 2023-09-26 06:13:38
合計ジャッジ時間 3,847 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(void){
  int n;
  cin>>n;
  unsigned long long sum[10]={0};
  
  bool ans = true;
  
  for(int i = 1 ; i <= n ; i ++){
    sum[0] += i;
    sum[1] += 1 + i;
    sum[2] += 2 + i;
    sum[3] += 3 + i;
    sum[4] += 4 + i;
    sum[5] += 5 + i;
    sum[6] += 6 + i;
    sum[7] += 7 + i;
    sum[8] += 8 + i;
    sum[9] += 9 + 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 < 10 ; i ++){
    unsigned long long  num = sum[i];
    //cout<<sum[i]<<endl;
    gcd = __gcd(gcd,num);
  }
  cout<<gcd<<endl;
 
}
0