結果

問題 No.1262 グラフを作ろう!
ユーザー kiyoshi0205kiyoshi0205
提出日時 2020-10-16 23:45:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,447 ms / 3,000 ms
コード長 2,439 bytes
コンパイル時間 2,504 ms
コンパイル使用メモリ 180,304 KB
実行使用メモリ 125,496 KB
最終ジャッジ日時 2023-09-28 06:30:54
合計ジャッジ時間 180,087 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,831 ms
123,328 KB
testcase_01 AC 1,697 ms
122,876 KB
testcase_02 AC 1,789 ms
123,964 KB
testcase_03 AC 1,668 ms
122,564 KB
testcase_04 AC 1,512 ms
124,644 KB
testcase_05 AC 1,648 ms
123,596 KB
testcase_06 AC 1,483 ms
125,164 KB
testcase_07 AC 1,577 ms
122,884 KB
testcase_08 AC 1,665 ms
124,768 KB
testcase_09 AC 1,578 ms
122,560 KB
testcase_10 AC 1,585 ms
122,724 KB
testcase_11 AC 1,722 ms
125,112 KB
testcase_12 AC 1,703 ms
123,144 KB
testcase_13 AC 1,637 ms
122,632 KB
testcase_14 AC 1,588 ms
123,044 KB
testcase_15 AC 2,447 ms
122,696 KB
testcase_16 AC 1,659 ms
124,432 KB
testcase_17 AC 1,912 ms
123,796 KB
testcase_18 AC 1,777 ms
124,396 KB
testcase_19 AC 1,757 ms
124,312 KB
testcase_20 AC 1,551 ms
125,496 KB
testcase_21 AC 2,006 ms
123,984 KB
testcase_22 AC 1,429 ms
124,292 KB
testcase_23 AC 1,803 ms
122,836 KB
testcase_24 AC 1,613 ms
124,584 KB
testcase_25 AC 1,714 ms
123,016 KB
testcase_26 AC 1,496 ms
123,356 KB
testcase_27 AC 1,809 ms
124,488 KB
testcase_28 AC 1,626 ms
124,028 KB
testcase_29 AC 1,751 ms
124,444 KB
testcase_30 AC 1,696 ms
123,268 KB
testcase_31 AC 1,934 ms
123,252 KB
testcase_32 AC 1,853 ms
123,432 KB
testcase_33 AC 1,686 ms
122,732 KB
testcase_34 AC 1,804 ms
125,240 KB
testcase_35 AC 1,837 ms
122,596 KB
testcase_36 AC 1,726 ms
122,736 KB
testcase_37 AC 2,003 ms
124,400 KB
testcase_38 AC 1,851 ms
124,056 KB
testcase_39 AC 1,737 ms
122,632 KB
testcase_40 AC 1,782 ms
122,644 KB
testcase_41 AC 1,718 ms
124,644 KB
testcase_42 AC 1,935 ms
124,712 KB
testcase_43 AC 1,777 ms
123,856 KB
testcase_44 AC 1,765 ms
123,632 KB
testcase_45 AC 1,862 ms
124,948 KB
testcase_46 AC 1,664 ms
125,252 KB
testcase_47 AC 1,692 ms
122,612 KB
testcase_48 AC 1,931 ms
124,544 KB
testcase_49 AC 1,898 ms
124,300 KB
testcase_50 AC 1,854 ms
124,680 KB
testcase_51 AC 1,691 ms
122,644 KB
testcase_52 AC 1,728 ms
125,068 KB
testcase_53 AC 1,671 ms
122,568 KB
testcase_54 AC 1,806 ms
122,912 KB
testcase_55 AC 1,757 ms
123,132 KB
testcase_56 AC 1,716 ms
124,704 KB
testcase_57 AC 1,973 ms
124,948 KB
testcase_58 AC 1,757 ms
122,768 KB
testcase_59 AC 1,719 ms
124,776 KB
testcase_60 AC 1,966 ms
124,892 KB
testcase_61 AC 1,778 ms
122,948 KB
testcase_62 AC 1,983 ms
123,900 KB
testcase_63 AC 1,843 ms
122,964 KB
testcase_64 AC 1,817 ms
123,088 KB
testcase_65 AC 1,676 ms
123,288 KB
testcase_66 AC 1,769 ms
122,980 KB
testcase_67 AC 1,718 ms
123,592 KB
testcase_68 AC 1,709 ms
125,248 KB
testcase_69 AC 1,739 ms
123,412 KB
testcase_70 AC 1,878 ms
124,384 KB
testcase_71 AC 1,779 ms
123,228 KB
testcase_72 AC 1,937 ms
124,208 KB
testcase_73 AC 1,802 ms
123,368 KB
testcase_74 AC 1,724 ms
122,780 KB
testcase_75 AC 1,781 ms
123,284 KB
testcase_76 AC 1,785 ms
123,148 KB
testcase_77 AC 1,774 ms
123,028 KB
testcase_78 AC 1,824 ms
123,460 KB
testcase_79 AC 1,900 ms
124,176 KB
testcase_80 AC 1,910 ms
124,660 KB
testcase_81 AC 1,724 ms
122,896 KB
testcase_82 AC 1,800 ms
123,032 KB
testcase_83 AC 1,859 ms
124,204 KB
testcase_84 AC 1,736 ms
123,192 KB
testcase_85 AC 1,882 ms
124,124 KB
testcase_86 AC 1,768 ms
123,244 KB
testcase_87 AC 1,836 ms
123,768 KB
testcase_88 AC 1,748 ms
122,864 KB
testcase_89 AC 1,827 ms
124,280 KB
testcase_90 AC 1,686 ms
122,776 KB
testcase_91 AC 1,668 ms
122,632 KB
testcase_92 AC 1,693 ms
122,632 KB
testcase_93 AC 1,685 ms
122,712 KB
testcase_94 AC 1,690 ms
122,608 KB
testcase_95 AC 1,865 ms
125,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(x) cout<<x<<endl
#define printyes print("Yes")
#define printno print("No")
#define printYES print("YES")
#define printNO print("NO")
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI=acos(-1);
const double eps=1e-9;
template<class T,class E> ostream& operator<<(ostream& os,pair<T,E>& p){return os<<"{"<<p.first<<","<<p.second<<"}";}
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;}
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout<<fixed<<setprecision(15);
}

int M,phi[1000001],lis[10000001];
ll ans;
vector<int> divisor[1000001];
int main(){
  startupcpp();
  int i,j;
  for(i=1;i<1000001;++i){
    phi[i]=i-phi[i];
    for(j=i;j<1000001;j+=i){
      divisor[j].eb(i);
      if(j!=i)phi[j]+=phi[i];
    }
  }
  cin>>M>>M;
  while(M--){
    cin>>i;
    // ans=0;
    if(lis[i]){
      ans+=lis[i];
      continue;
    }
    for(auto d:divisor[i]){
      lis[i]+=(i-1)%d*phi[i/d];
    }
    ans+=lis[i];
    // print(ans);
  }
  print(ans);
}
0