結果

問題 No.1262 グラフを作ろう!
ユーザー suta28407928suta28407928
提出日時 2020-10-17 01:36:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 442 ms / 3,000 ms
コード長 2,271 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 113,836 KB
実行使用メモリ 26,568 KB
最終ジャッジ日時 2023-09-28 07:12:18
合計ジャッジ時間 32,304 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
17,020 KB
testcase_01 AC 202 ms
13,420 KB
testcase_02 AC 335 ms
19,868 KB
testcase_03 AC 279 ms
13,660 KB
testcase_04 AC 112 ms
16,024 KB
testcase_05 AC 178 ms
14,968 KB
testcase_06 AC 138 ms
18,116 KB
testcase_07 AC 39 ms
6,472 KB
testcase_08 AC 261 ms
20,428 KB
testcase_09 AC 187 ms
10,104 KB
testcase_10 AC 152 ms
11,680 KB
testcase_11 AC 304 ms
21,636 KB
testcase_12 AC 276 ms
15,828 KB
testcase_13 AC 287 ms
14,256 KB
testcase_14 AC 134 ms
12,152 KB
testcase_15 AC 162 ms
8,896 KB
testcase_16 AC 253 ms
19,588 KB
testcase_17 AC 214 ms
16,932 KB
testcase_18 AC 315 ms
21,584 KB
testcase_19 AC 80 ms
14,664 KB
testcase_20 AC 179 ms
20,572 KB
testcase_21 AC 326 ms
20,264 KB
testcase_22 AC 59 ms
13,440 KB
testcase_23 AC 178 ms
10,900 KB
testcase_24 AC 239 ms
20,120 KB
testcase_25 AC 53 ms
9,828 KB
testcase_26 AC 88 ms
11,896 KB
testcase_27 AC 206 ms
17,824 KB
testcase_28 AC 170 ms
15,692 KB
testcase_29 AC 152 ms
16,340 KB
testcase_30 AC 124 ms
12,244 KB
testcase_31 AC 326 ms
18,124 KB
testcase_32 AC 195 ms
14,980 KB
testcase_33 AC 85 ms
6,748 KB
testcase_34 AC 223 ms
21,176 KB
testcase_35 AC 265 ms
14,256 KB
testcase_36 AC 95 ms
6,940 KB
testcase_37 AC 340 ms
22,280 KB
testcase_38 AC 193 ms
16,980 KB
testcase_39 AC 170 ms
10,044 KB
testcase_40 AC 156 ms
11,412 KB
testcase_41 AC 139 ms
17,656 KB
testcase_42 AC 299 ms
21,404 KB
testcase_43 AC 156 ms
15,008 KB
testcase_44 AC 176 ms
14,784 KB
testcase_45 AC 295 ms
22,276 KB
testcase_46 AC 148 ms
19,524 KB
testcase_47 AC 202 ms
10,428 KB
testcase_48 AC 243 ms
19,528 KB
testcase_49 AC 364 ms
21,320 KB
testcase_50 AC 303 ms
21,488 KB
testcase_51 AC 233 ms
11,892 KB
testcase_52 AC 186 ms
18,852 KB
testcase_53 AC 64 ms
8,324 KB
testcase_54 AC 311 ms
16,292 KB
testcase_55 AC 231 ms
14,736 KB
testcase_56 AC 158 ms
17,076 KB
testcase_57 AC 412 ms
24,428 KB
testcase_58 AC 276 ms
14,772 KB
testcase_59 AC 131 ms
17,924 KB
testcase_60 AC 336 ms
23,100 KB
testcase_61 AC 137 ms
11,368 KB
testcase_62 AC 303 ms
19,592 KB
testcase_63 AC 309 ms
15,752 KB
testcase_64 AC 203 ms
14,200 KB
testcase_65 AC 82 ms
11,420 KB
testcase_66 AC 143 ms
12,192 KB
testcase_67 AC 111 ms
13,152 KB
testcase_68 AC 133 ms
19,312 KB
testcase_69 AC 118 ms
12,688 KB
testcase_70 AC 298 ms
22,364 KB
testcase_71 AC 226 ms
18,024 KB
testcase_72 AC 289 ms
22,888 KB
testcase_73 AC 345 ms
21,708 KB
testcase_74 AC 310 ms
18,344 KB
testcase_75 AC 277 ms
19,620 KB
testcase_76 AC 228 ms
17,484 KB
testcase_77 AC 295 ms
18,920 KB
testcase_78 AC 271 ms
19,596 KB
testcase_79 AC 333 ms
24,324 KB
testcase_80 AC 255 ms
22,456 KB
testcase_81 AC 288 ms
18,400 KB
testcase_82 AC 356 ms
20,272 KB
testcase_83 AC 284 ms
21,324 KB
testcase_84 AC 229 ms
17,956 KB
testcase_85 AC 400 ms
24,752 KB
testcase_86 AC 301 ms
19,600 KB
testcase_87 AC 341 ms
22,640 KB
testcase_88 AC 279 ms
18,232 KB
testcase_89 AC 222 ms
20,392 KB
testcase_90 AC 382 ms
26,568 KB
testcase_91 AC 397 ms
26,392 KB
testcase_92 AC 400 ms
26,516 KB
testcase_93 AC 442 ms
26,524 KB
testcase_94 AC 386 ms
26,516 KB
testcase_95 AC 374 ms
26,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-10;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll GCD(ll a, ll b){
	if(b==0) return a;
	else return GCD(b,a%b);
}

int main(){
	int n,m; cin >> n >> m;
	vl a(m); rep(i,m) cin >> a[i];
	ll ans = 0;
	vl cnt(n+1,0);
	vl add(n+1,0);
	for(int i=1; i<=n; i++){
		add[i] += i;
		cnt[i] += add[i];
		for(int j=i+i; j<=n; j+=i){
			cnt[j] += add[i] * (j / i);
			add[j] -= add[i];
		}
	}
	rep(i,m){
		ans += cnt[a[i]] - a[i];
	}
	cout << ans << "\n";
}
0