結果

問題 No.1262 グラフを作ろう!
ユーザー kiyoshi0205kiyoshi0205
提出日時 2020-10-16 23:46:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,252 ms / 3,000 ms
コード長 2,438 bytes
コンパイル時間 4,271 ms
コンパイル使用メモリ 180,580 KB
実行使用メモリ 125,576 KB
最終ジャッジ日時 2023-09-28 06:37:54
合計ジャッジ時間 117,222 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,039 ms
123,252 KB
testcase_01 AC 1,972 ms
123,140 KB
testcase_02 AC 2,073 ms
123,920 KB
testcase_03 AC 1,956 ms
122,828 KB
testcase_04 AC 1,858 ms
124,576 KB
testcase_05 AC 1,952 ms
123,596 KB
testcase_06 AC 1,831 ms
125,160 KB
testcase_07 AC 1,942 ms
122,624 KB
testcase_08 AC 2,009 ms
124,696 KB
testcase_09 AC 1,956 ms
122,580 KB
testcase_10 AC 1,943 ms
122,792 KB
testcase_11 AC 2,033 ms
125,080 KB
testcase_12 AC 2,252 ms
123,048 KB
testcase_13 AC 2,002 ms
122,612 KB
testcase_14 AC 1,934 ms
122,952 KB
testcase_15 AC 1,878 ms
122,636 KB
testcase_16 AC 2,000 ms
124,696 KB
testcase_17 AC 1,983 ms
123,808 KB
testcase_18 AC 2,075 ms
124,392 KB
testcase_19 AC 1,920 ms
124,164 KB
testcase_20 AC 1,895 ms
125,276 KB
testcase_21 AC 2,063 ms
123,892 KB
testcase_22 AC 1,824 ms
123,976 KB
testcase_23 AC 1,901 ms
122,576 KB
testcase_24 AC 2,018 ms
124,592 KB
testcase_25 AC 1,829 ms
122,984 KB
testcase_26 AC 1,845 ms
123,348 KB
testcase_27 AC 2,049 ms
124,472 KB
testcase_28 AC 1,946 ms
124,024 KB
testcase_29 AC 1,987 ms
124,428 KB
testcase_30 AC 1,920 ms
123,192 KB
testcase_31 AC 2,032 ms
123,240 KB
testcase_32 AC 1,940 ms
123,292 KB
testcase_33 AC 1,861 ms
122,692 KB
testcase_34 AC 1,977 ms
125,152 KB
testcase_35 AC 1,954 ms
122,576 KB
testcase_36 AC 1,838 ms
122,596 KB
testcase_37 AC 2,059 ms
124,556 KB
testcase_38 AC 1,948 ms
124,120 KB
testcase_39 AC 1,896 ms
122,576 KB
testcase_40 AC 1,911 ms
122,656 KB
testcase_41 AC 1,871 ms
124,760 KB
testcase_42 AC 2,043 ms
124,876 KB
testcase_43 AC 1,954 ms
123,844 KB
testcase_44 AC 1,961 ms
123,736 KB
testcase_45 AC 2,022 ms
125,004 KB
testcase_46 AC 1,850 ms
125,576 KB
testcase_47 AC 1,881 ms
122,824 KB
testcase_48 AC 1,999 ms
124,672 KB
testcase_49 AC 2,071 ms
124,288 KB
testcase_50 AC 2,119 ms
124,612 KB
testcase_51 AC 1,905 ms
122,660 KB
testcase_52 AC 1,865 ms
125,072 KB
testcase_53 AC 1,851 ms
122,556 KB
testcase_54 AC 1,977 ms
123,216 KB
testcase_55 AC 1,976 ms
123,140 KB
testcase_56 AC 1,925 ms
124,488 KB
testcase_57 AC 2,090 ms
124,928 KB
testcase_58 AC 2,082 ms
122,736 KB
testcase_59 AC 1,985 ms
124,712 KB
testcase_60 AC 2,088 ms
124,996 KB
testcase_61 AC 1,890 ms
123,064 KB
testcase_62 AC 2,030 ms
124,144 KB
testcase_63 AC 1,967 ms
122,668 KB
testcase_64 AC 1,940 ms
123,348 KB
testcase_65 AC 1,874 ms
123,548 KB
testcase_66 AC 1,917 ms
123,148 KB
testcase_67 AC 1,875 ms
123,588 KB
testcase_68 AC 1,877 ms
125,252 KB
testcase_69 AC 1,899 ms
123,672 KB
testcase_70 AC 1,985 ms
124,420 KB
testcase_71 AC 1,898 ms
123,220 KB
testcase_72 AC 1,983 ms
124,440 KB
testcase_73 AC 2,189 ms
123,352 KB
testcase_74 AC 1,879 ms
122,936 KB
testcase_75 AC 1,926 ms
123,472 KB
testcase_76 AC 1,895 ms
123,132 KB
testcase_77 AC 1,908 ms
123,196 KB
testcase_78 AC 1,941 ms
123,704 KB
testcase_79 AC 2,028 ms
124,500 KB
testcase_80 AC 1,951 ms
124,368 KB
testcase_81 AC 1,941 ms
122,800 KB
testcase_82 AC 1,932 ms
123,128 KB
testcase_83 AC 1,939 ms
124,128 KB
testcase_84 AC 1,918 ms
123,296 KB
testcase_85 AC 2,013 ms
124,152 KB
testcase_86 AC 1,914 ms
123,240 KB
testcase_87 AC 1,994 ms
123,804 KB
testcase_88 AC 1,942 ms
122,804 KB
testcase_89 AC 1,990 ms
124,128 KB
testcase_90 AC 2,001 ms
122,740 KB
testcase_91 AC 2,056 ms
122,596 KB
testcase_92 AC 1,940 ms
122,636 KB
testcase_93 AC 1,955 ms
122,576 KB
testcase_94 AC 2,036 ms
122,636 KB
testcase_95 AC 2,159 ms
125,516 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[1000001];
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