結果

問題 No.2249 GCDistance
ユーザー Eki1009Eki1009
提出日時 2023-03-17 22:20:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 757 ms / 5,000 ms
コード長 302 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 200,932 KB
実行使用メモリ 120,860 KB
最終ジャッジ日時 2023-10-18 15:16:58
合計ジャッジ時間 11,318 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 394 ms
120,860 KB
testcase_01 AC 746 ms
120,860 KB
testcase_02 AC 747 ms
120,860 KB
testcase_03 AC 734 ms
120,860 KB
testcase_04 AC 512 ms
120,860 KB
testcase_05 AC 757 ms
120,860 KB
testcase_06 AC 752 ms
120,860 KB
testcase_07 AC 757 ms
120,860 KB
testcase_08 AC 412 ms
120,860 KB
testcase_09 AC 736 ms
120,860 KB
testcase_10 AC 686 ms
120,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int N=10000001;
int t,P[N];
long long C[N];
int main(){
  iota(P,P+N,0);
  for(int i=2;i<N;i++){
    if(P[i]==i)for(int j=i;j<N;j+=i)P[j]-=P[j]/i;
    C[i]=C[i-1]+2*(i-1)-P[i];
  }
  for(cin>>t;t--;){
    int n;
    cin>>n;
    cout<<C[n]<<'\n';
  }
}
0