結果

問題 No.1262 グラフを作ろう!
ユーザー 👑 kmjpkmjp
提出日時 2020-10-16 23:43:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,546 ms / 3,000 ms
コード長 1,219 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 201,228 KB
実行使用メモリ 19,300 KB
最終ジャッジ日時 2023-09-28 06:20:15
合計ジャッジ時間 249,421 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,518 ms
19,060 KB
testcase_01 AC 2,455 ms
19,092 KB
testcase_02 AC 2,522 ms
19,100 KB
testcase_03 AC 2,487 ms
19,064 KB
testcase_04 AC 2,407 ms
19,188 KB
testcase_05 AC 2,446 ms
19,196 KB
testcase_06 AC 2,391 ms
19,104 KB
testcase_07 AC 2,400 ms
19,192 KB
testcase_08 AC 2,474 ms
19,080 KB
testcase_09 AC 2,462 ms
19,024 KB
testcase_10 AC 2,454 ms
19,032 KB
testcase_11 AC 2,475 ms
19,188 KB
testcase_12 AC 2,482 ms
19,064 KB
testcase_13 AC 2,474 ms
19,024 KB
testcase_14 AC 2,430 ms
19,092 KB
testcase_15 AC 2,428 ms
19,108 KB
testcase_16 AC 2,491 ms
19,064 KB
testcase_17 AC 2,477 ms
19,052 KB
testcase_18 AC 2,524 ms
19,196 KB
testcase_19 AC 2,407 ms
19,024 KB
testcase_20 AC 2,441 ms
19,108 KB
testcase_21 AC 2,526 ms
19,100 KB
testcase_22 AC 2,403 ms
19,040 KB
testcase_23 AC 2,455 ms
19,128 KB
testcase_24 AC 2,486 ms
19,124 KB
testcase_25 AC 2,384 ms
19,052 KB
testcase_26 AC 2,403 ms
19,056 KB
testcase_27 AC 2,435 ms
19,036 KB
testcase_28 AC 2,450 ms
19,052 KB
testcase_29 AC 2,411 ms
19,188 KB
testcase_30 AC 2,428 ms
19,052 KB
testcase_31 AC 2,497 ms
19,236 KB
testcase_32 AC 2,440 ms
19,096 KB
testcase_33 AC 2,404 ms
19,048 KB
testcase_34 AC 2,457 ms
19,052 KB
testcase_35 AC 2,495 ms
19,108 KB
testcase_36 AC 2,407 ms
19,096 KB
testcase_37 AC 2,525 ms
19,028 KB
testcase_38 AC 2,458 ms
19,036 KB
testcase_39 AC 2,445 ms
19,028 KB
testcase_40 AC 2,449 ms
19,056 KB
testcase_41 AC 2,418 ms
19,048 KB
testcase_42 AC 2,511 ms
19,288 KB
testcase_43 AC 2,467 ms
19,192 KB
testcase_44 AC 2,459 ms
19,240 KB
testcase_45 AC 2,495 ms
19,108 KB
testcase_46 AC 2,414 ms
19,056 KB
testcase_47 AC 2,454 ms
19,092 KB
testcase_48 AC 2,491 ms
19,104 KB
testcase_49 AC 2,530 ms
19,060 KB
testcase_50 AC 2,497 ms
19,232 KB
testcase_51 AC 2,461 ms
19,100 KB
testcase_52 AC 2,423 ms
19,296 KB
testcase_53 AC 2,408 ms
19,032 KB
testcase_54 AC 2,495 ms
19,056 KB
testcase_55 AC 2,471 ms
19,044 KB
testcase_56 AC 2,428 ms
19,060 KB
testcase_57 AC 2,546 ms
19,032 KB
testcase_58 AC 2,484 ms
19,300 KB
testcase_59 AC 2,437 ms
19,088 KB
testcase_60 AC 2,529 ms
19,092 KB
testcase_61 AC 2,430 ms
19,064 KB
testcase_62 AC 2,518 ms
19,056 KB
testcase_63 AC 2,480 ms
19,052 KB
testcase_64 AC 2,463 ms
19,096 KB
testcase_65 AC 2,413 ms
19,024 KB
testcase_66 AC 2,428 ms
19,188 KB
testcase_67 AC 2,426 ms
19,024 KB
testcase_68 AC 2,412 ms
19,092 KB
testcase_69 AC 2,428 ms
19,164 KB
testcase_70 AC 2,464 ms
19,036 KB
testcase_71 AC 2,450 ms
19,080 KB
testcase_72 AC 2,474 ms
19,100 KB
testcase_73 AC 2,478 ms
19,024 KB
testcase_74 AC 2,457 ms
19,024 KB
testcase_75 AC 2,455 ms
19,020 KB
testcase_76 AC 2,462 ms
19,064 KB
testcase_77 AC 2,464 ms
19,032 KB
testcase_78 AC 2,455 ms
19,064 KB
testcase_79 AC 2,486 ms
19,088 KB
testcase_80 AC 2,460 ms
19,028 KB
testcase_81 AC 2,456 ms
19,232 KB
testcase_82 AC 2,479 ms
19,188 KB
testcase_83 AC 2,470 ms
19,104 KB
testcase_84 AC 2,453 ms
19,092 KB
testcase_85 AC 2,501 ms
19,076 KB
testcase_86 AC 2,466 ms
19,128 KB
testcase_87 AC 2,500 ms
19,080 KB
testcase_88 AC 2,460 ms
19,124 KB
testcase_89 AC 2,462 ms
19,044 KB
testcase_90 AC 2,475 ms
19,104 KB
testcase_91 AC 2,466 ms
19,104 KB
testcase_92 AC 2,486 ms
19,124 KB
testcase_93 AC 2,494 ms
19,028 KB
testcase_94 AC 2,480 ms
19,028 KB
testcase_95 AC 2,479 ms
19,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[1010101];
ll sum[1010101];
int phi[1010101];
int di[1010101];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	
	for(i=1;i<=1000000;i++) phi[i]=i;
	for(i=2;i<=1000000;i++) if(di[i]==0) {
		for(j=i;j<=1000000;j+=i) di[j]=i, phi[j]=phi[j]/i*(i-1);
	}
	
	sum[1]=1;
	for(i=2;i<=1000000;i++) {
		for(j=1;j*j<=i;j++) if(i%j==0) {
			sum[i]+=(ll)j*phi[i/j];
			if(j*j!=i) sum[i]+=(ll)(i/j)*phi[j];
		}
	}
	
	ll ret=0;
	FOR(i,M) {
		cin>>x;
		ret+=sum[x]-x;
	}
	
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0