結果

問題 No.1262 グラフを作ろう!
ユーザー carrot46carrot46
提出日時 2020-10-16 23:27:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,089 ms / 3,000 ms
コード長 1,233 bytes
コンパイル時間 3,563 ms
コンパイル使用メモリ 170,052 KB
実行使用メモリ 88,928 KB
最終ジャッジ日時 2023-09-28 05:37:27
合計ジャッジ時間 73,329 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 626 ms
41,456 KB
testcase_01 AC 453 ms
34,140 KB
testcase_02 AC 771 ms
57,872 KB
testcase_03 AC 423 ms
20,872 KB
testcase_04 AC 598 ms
71,268 KB
testcase_05 AC 550 ms
50,112 KB
testcase_06 AC 707 ms
84,292 KB
testcase_07 AC 121 ms
16,980 KB
testcase_08 AC 799 ms
74,220 KB
testcase_09 AC 253 ms
13,816 KB
testcase_10 AC 368 ms
30,844 KB
testcase_11 AC 884 ms
82,104 KB
testcase_12 AC 557 ms
36,180 KB
testcase_13 AC 466 ms
23,920 KB
testcase_14 AC 393 ms
36,024 KB
testcase_15 AC 191 ms
9,896 KB
testcase_16 AC 758 ms
68,456 KB
testcase_17 AC 615 ms
54,336 KB
testcase_18 AC 848 ms
67,292 KB
testcase_19 AC 555 ms
62,836 KB
testcase_20 AC 843 ms
87,344 KB
testcase_21 AC 800 ms
56,800 KB
testcase_22 AC 491 ms
58,076 KB
testcase_23 AC 306 ms
20,272 KB
testcase_24 AC 817 ms
71,920 KB
testcase_25 AC 312 ms
37,600 KB
testcase_26 AC 430 ms
43,280 KB
testcase_27 AC 783 ms
69,672 KB
testcase_28 AC 663 ms
59,420 KB
testcase_29 AC 697 ms
66,856 KB
testcase_30 AC 452 ms
41,260 KB
testcase_31 AC 702 ms
42,196 KB
testcase_32 AC 522 ms
43,256 KB
testcase_33 AC 123 ms
10,704 KB
testcase_34 AC 862 ms
84,256 KB
testcase_35 AC 479 ms
27,676 KB
testcase_36 AC 124 ms
8,980 KB
testcase_37 AC 879 ms
67,320 KB
testcase_38 AC 645 ms
60,324 KB
testcase_39 AC 271 ms
17,440 KB
testcase_40 AC 355 ms
29,100 KB
testcase_41 AC 683 ms
73,500 KB
testcase_42 AC 849 ms
71,424 KB
testcase_43 AC 556 ms
52,544 KB
testcase_44 AC 529 ms
46,204 KB
testcase_45 AC 904 ms
79,384 KB
testcase_46 AC 795 ms
86,864 KB
testcase_47 AC 237 ms
10,160 KB
testcase_48 AC 776 ms
66,716 KB
testcase_49 AC 845 ms
64,196 KB
testcase_50 AC 877 ms
72,604 KB
testcase_51 AC 344 ms
19,564 KB
testcase_52 AC 762 ms
81,008 KB
testcase_53 AC 228 ms
25,560 KB
testcase_54 AC 582 ms
34,924 KB
testcase_55 AC 539 ms
40,248 KB
testcase_56 AC 669 ms
69,752 KB
testcase_57 AC 1,016 ms
79,836 KB
testcase_58 AC 495 ms
30,096 KB
testcase_59 AC 701 ms
74,296 KB
testcase_60 AC 964 ms
73,996 KB
testcase_61 AC 375 ms
32,800 KB
testcase_62 AC 751 ms
56,236 KB
testcase_63 AC 537 ms
29,836 KB
testcase_64 AC 487 ms
38,884 KB
testcase_65 AC 374 ms
43,304 KB
testcase_66 AC 390 ms
36,344 KB
testcase_67 AC 466 ms
49,240 KB
testcase_68 AC 775 ms
86,700 KB
testcase_69 AC 442 ms
44,844 KB
testcase_70 AC 928 ms
82,556 KB
testcase_71 AC 682 ms
59,972 KB
testcase_72 AC 961 ms
80,068 KB
testcase_73 AC 811 ms
61,556 KB
testcase_74 AC 632 ms
46,452 KB
testcase_75 AC 733 ms
61,364 KB
testcase_76 AC 655 ms
58,072 KB
testcase_77 AC 668 ms
53,516 KB
testcase_78 AC 751 ms
64,628 KB
testcase_79 AC 1,000 ms
81,340 KB
testcase_80 AC 935 ms
85,232 KB
testcase_81 AC 657 ms
51,536 KB
testcase_82 AC 763 ms
55,448 KB
testcase_83 AC 884 ms
79,996 KB
testcase_84 AC 663 ms
59,140 KB
testcase_85 AC 1,006 ms
79,696 KB
testcase_86 AC 750 ms
60,004 KB
testcase_87 AC 902 ms
72,236 KB
testcase_88 AC 649 ms
50,916 KB
testcase_89 AC 818 ms
76,340 KB
testcase_90 AC 1,063 ms
88,840 KB
testcase_91 AC 1,056 ms
88,928 KB
testcase_92 AC 1,038 ms
88,700 KB
testcase_93 AC 1,089 ms
88,644 KB
testcase_94 AC 1,046 ms
88,496 KB
testcase_95 AC 1,033 ms
88,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<48);

int main() {
    cin>>N>>M;
    vec euler(N + 1, 1), res(N + 1, 0);
    mat prime(N + 1, vec(0));
    reps(i, 2, N+1){
        if(prime[i].empty()){
            for(int j = i; j <= N; j += i){
                prime[j].push_back(i);
            }
        }
    }
    reps(i, 1, N + 1){
        int temp(i);
        for(ll v : prime[i]){
            int k(0), tt(temp);
            while(temp%v == 0){
                temp /= v;
                ++k;
            }
            tt /= temp;
            euler[i] *= tt - tt / v;
        }
    }
    reps(i, 1, N + 1){
        for(int j = 1; j * i <= N; ++j) res[j * i] += euler[i] * j;
        res[i] -= i;
    }
    ll Res(0);
    rep(i, M){
        cin>>A;
        Res += res[A];
    }
    cout<<Res<<endl;
}
0