結果

問題 No.1262 グラフを作ろう!
ユーザー 沙耶花沙耶花
提出日時 2020-10-16 23:22:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 197 ms / 3,000 ms
コード長 563 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 200,264 KB
実行使用メモリ 18,772 KB
最終ジャッジ日時 2023-09-28 05:20:59
合計ジャッジ時間 19,838 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
10,208 KB
testcase_01 AC 97 ms
8,776 KB
testcase_02 AC 147 ms
13,448 KB
testcase_03 AC 117 ms
6,564 KB
testcase_04 AC 73 ms
15,436 KB
testcase_05 AC 90 ms
11,732 KB
testcase_06 AC 92 ms
17,704 KB
testcase_07 AC 22 ms
5,692 KB
testcase_08 AC 138 ms
16,076 KB
testcase_09 AC 77 ms
5,148 KB
testcase_10 AC 78 ms
8,164 KB
testcase_11 AC 157 ms
17,480 KB
testcase_12 AC 125 ms
9,412 KB
testcase_13 AC 121 ms
6,992 KB
testcase_14 AC 71 ms
9,044 KB
testcase_15 AC 59 ms
4,380 KB
testcase_16 AC 136 ms
15,176 KB
testcase_17 AC 115 ms
12,436 KB
testcase_18 AC 160 ms
14,728 KB
testcase_19 AC 67 ms
13,964 KB
testcase_20 AC 128 ms
18,544 KB
testcase_21 AC 166 ms
12,880 KB
testcase_22 AC 53 ms
13,084 KB
testcase_23 AC 80 ms
6,468 KB
testcase_24 AC 132 ms
15,716 KB
testcase_25 AC 39 ms
9,344 KB
testcase_26 AC 53 ms
10,356 KB
testcase_27 AC 103 ms
15,340 KB
testcase_28 AC 85 ms
13,428 KB
testcase_29 AC 81 ms
14,912 KB
testcase_30 AC 68 ms
10,024 KB
testcase_31 AC 153 ms
10,460 KB
testcase_32 AC 99 ms
10,376 KB
testcase_33 AC 35 ms
4,872 KB
testcase_34 AC 136 ms
17,720 KB
testcase_35 AC 116 ms
7,540 KB
testcase_36 AC 36 ms
4,384 KB
testcase_37 AC 166 ms
14,732 KB
testcase_38 AC 108 ms
13,676 KB
testcase_39 AC 76 ms
5,756 KB
testcase_40 AC 72 ms
7,736 KB
testcase_41 AC 97 ms
16,064 KB
testcase_42 AC 159 ms
15,452 KB
testcase_43 AC 89 ms
12,188 KB
testcase_44 AC 92 ms
11,104 KB
testcase_45 AC 156 ms
17,056 KB
testcase_46 AC 110 ms
18,308 KB
testcase_47 AC 78 ms
4,396 KB
testcase_48 AC 130 ms
14,680 KB
testcase_49 AC 165 ms
14,468 KB
testcase_50 AC 155 ms
15,984 KB
testcase_51 AC 89 ms
6,500 KB
testcase_52 AC 106 ms
17,248 KB
testcase_53 AC 34 ms
7,260 KB
testcase_54 AC 134 ms
9,084 KB
testcase_55 AC 107 ms
9,788 KB
testcase_56 AC 90 ms
15,192 KB
testcase_57 AC 194 ms
16,968 KB
testcase_58 AC 115 ms
8,100 KB
testcase_59 AC 97 ms
15,920 KB
testcase_60 AC 175 ms
16,064 KB
testcase_61 AC 67 ms
8,460 KB
testcase_62 AC 144 ms
12,864 KB
testcase_63 AC 128 ms
8,092 KB
testcase_64 AC 96 ms
9,824 KB
testcase_65 AC 52 ms
10,520 KB
testcase_66 AC 71 ms
9,472 KB
testcase_67 AC 66 ms
11,356 KB
testcase_68 AC 105 ms
18,236 KB
testcase_69 AC 72 ms
10,588 KB
testcase_70 AC 157 ms
17,500 KB
testcase_71 AC 115 ms
13,664 KB
testcase_72 AC 167 ms
16,904 KB
testcase_73 AC 162 ms
13,616 KB
testcase_74 AC 131 ms
11,080 KB
testcase_75 AC 130 ms
13,660 KB
testcase_76 AC 111 ms
13,080 KB
testcase_77 AC 129 ms
12,500 KB
testcase_78 AC 129 ms
14,340 KB
testcase_79 AC 180 ms
17,276 KB
testcase_80 AC 153 ms
18,128 KB
testcase_81 AC 129 ms
11,936 KB
testcase_82 AC 152 ms
12,704 KB
testcase_83 AC 148 ms
17,296 KB
testcase_84 AC 116 ms
13,512 KB
testcase_85 AC 196 ms
17,056 KB
testcase_86 AC 133 ms
13,432 KB
testcase_87 AC 169 ms
15,672 KB
testcase_88 AC 126 ms
11,888 KB
testcase_89 AC 136 ms
16,500 KB
testcase_90 AC 195 ms
18,732 KB
testcase_91 AC 194 ms
18,764 KB
testcase_92 AC 197 ms
18,772 KB
testcase_93 AC 196 ms
18,740 KB
testcase_94 AC 194 ms
18,736 KB
testcase_95 AC 190 ms
18,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int main(){	
	
	int N,M;
	cin>>N>>M;
	
	
	

	vector<long long> temp(N+1,0LL);
	
	for(int i=1;i<=N;i++){
		temp[i] += i;
		for(int j=i*2;j<=N;j+=i){
			temp[j] -= temp[i];
		}
	}
	
	vector<long long> ans(N+1,0);
	
	for(int i=1;i<=N;i++){
		for(int j=i;j<=N;j+=i){
			ans[j] += temp[i] * (j/i);
		}
	}
	
	long long Ans = 0LL;
	
	rep(i,M){
		int A;
		scanf("%d",&A);
		Ans += ans[A] - A;
	}
	
	cout<<Ans<<endl;
	
    return 0;
}

0