結果

問題 No.1262 グラフを作ろう!
ユーザー nok0nok0
提出日時 2020-08-27 10:44:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 608 ms / 3,000 ms
コード長 3,862 bytes
コンパイル時間 3,177 ms
コンパイル使用メモリ 224,980 KB
実行使用メモリ 11,972 KB
最終ジャッジ日時 2023-09-28 02:16:56
合計ジャッジ時間 30,545 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 305 ms
11,724 KB
testcase_01 AC 213 ms
11,876 KB
testcase_02 AC 321 ms
11,668 KB
testcase_03 AC 320 ms
11,676 KB
testcase_04 AC 33 ms
11,928 KB
testcase_05 AC 158 ms
11,776 KB
testcase_06 AC 23 ms
11,840 KB
testcase_07 AC 43 ms
11,732 KB
testcase_08 AC 209 ms
11,944 KB
testcase_09 AC 216 ms
11,776 KB
testcase_10 AC 156 ms
11,884 KB
testcase_11 AC 221 ms
11,728 KB
testcase_12 AC 311 ms
11,732 KB
testcase_13 AC 317 ms
11,776 KB
testcase_14 AC 135 ms
11,900 KB
testcase_15 AC 184 ms
11,928 KB
testcase_16 AC 225 ms
11,812 KB
testcase_17 AC 214 ms
11,776 KB
testcase_18 AC 330 ms
11,880 KB
testcase_19 AC 45 ms
11,732 KB
testcase_20 AC 110 ms
11,832 KB
testcase_21 AC 367 ms
11,668 KB
testcase_22 AC 22 ms
11,728 KB
testcase_23 AC 202 ms
11,840 KB
testcase_24 AC 222 ms
11,724 KB
testcase_25 AC 36 ms
11,664 KB
testcase_26 AC 66 ms
11,972 KB
testcase_27 AC 129 ms
11,808 KB
testcase_28 AC 116 ms
11,932 KB
testcase_29 AC 78 ms
11,892 KB
testcase_30 AC 104 ms
11,852 KB
testcase_31 AC 330 ms
11,676 KB
testcase_32 AC 194 ms
11,924 KB
testcase_33 AC 98 ms
11,724 KB
testcase_34 AC 167 ms
11,780 KB
testcase_35 AC 293 ms
11,676 KB
testcase_36 AC 114 ms
11,724 KB
testcase_37 AC 347 ms
11,932 KB
testcase_38 AC 177 ms
11,668 KB
testcase_39 AC 200 ms
11,840 KB
testcase_40 AC 170 ms
11,968 KB
testcase_41 AC 95 ms
11,728 KB
testcase_42 AC 289 ms
11,724 KB
testcase_43 AC 141 ms
11,876 KB
testcase_44 AC 181 ms
11,728 KB
testcase_45 AC 264 ms
11,968 KB
testcase_46 AC 66 ms
11,848 KB
testcase_47 AC 259 ms
11,832 KB
testcase_48 AC 244 ms
11,928 KB
testcase_49 AC 351 ms
11,880 KB
testcase_50 AC 269 ms
11,848 KB
testcase_51 AC 255 ms
11,728 KB
testcase_52 AC 82 ms
11,668 KB
testcase_53 AC 63 ms
11,808 KB
testcase_54 AC 337 ms
11,776 KB
testcase_55 AC 230 ms
11,880 KB
testcase_56 AC 101 ms
11,968 KB
testcase_57 AC 422 ms
11,668 KB
testcase_58 AC 333 ms
11,848 KB
testcase_59 AC 105 ms
11,780 KB
testcase_60 AC 412 ms
11,932 KB
testcase_61 AC 146 ms
11,720 KB
testcase_62 AC 329 ms
11,728 KB
testcase_63 AC 354 ms
11,964 KB
testcase_64 AC 220 ms
11,840 KB
testcase_65 AC 57 ms
11,728 KB
testcase_66 AC 150 ms
11,844 KB
testcase_67 AC 96 ms
11,944 KB
testcase_68 AC 62 ms
11,844 KB
testcase_69 AC 113 ms
11,876 KB
testcase_70 AC 259 ms
11,972 KB
testcase_71 AC 234 ms
11,880 KB
testcase_72 AC 309 ms
11,880 KB
testcase_73 AC 378 ms
11,968 KB
testcase_74 AC 314 ms
11,832 KB
testcase_75 AC 270 ms
11,836 KB
testcase_76 AC 213 ms
11,848 KB
testcase_77 AC 303 ms
11,676 KB
testcase_78 AC 255 ms
11,668 KB
testcase_79 AC 342 ms
11,924 KB
testcase_80 AC 226 ms
11,812 KB
testcase_81 AC 290 ms
11,880 KB
testcase_82 AC 360 ms
11,880 KB
testcase_83 AC 224 ms
11,892 KB
testcase_84 AC 224 ms
11,732 KB
testcase_85 AC 370 ms
11,780 KB
testcase_86 AC 287 ms
11,848 KB
testcase_87 AC 359 ms
11,732 KB
testcase_88 AC 288 ms
11,676 KB
testcase_89 AC 219 ms
11,672 KB
testcase_90 AC 156 ms
11,732 KB
testcase_91 AC 158 ms
11,884 KB
testcase_92 AC 158 ms
11,776 KB
testcase_93 AC 507 ms
11,848 KB
testcase_94 AC 608 ms
11,676 KB
testcase_95 AC 341 ms
11,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
struct inputoutputfaster{
    inputoutputfaster(){
        ios::sync_with_stdio(false);\
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
}inputoutputfaster_;
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T divup(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

const int MAX = 1e6;
V<> lp(1000010, 0), pr;
struct Make_Table{
    Make_Table(){
        for(int i = 2; i <= MAX; i++){
            if(!lp[i]){
                lp[i] = i;
                pr.pb(i);
            }
            for(int j = 0; j < SZ(pr) and pr[j] <= lp[i] and i * pr[j] <= MAX; j++){
                lp[i * pr[j]] = pr[j];
            }
        }
    }
}Make_Table_;

ll res, a;
unordered_map<int, int> mp;
void solve(){
    res -= a;
    mp.clear();
    while(lp[a]){
        mp[lp[a]]++;
        a = a / lp[a];
    }
    if(a != 1) mp[a]++;
    ll pre = 1;
    for(auto p : mp) pre *= pow(p.first, p.second - 1) * ((p.first - 1) * p.second + p.first);
    res += pre;
}

int main(){
    INT(n, m);
    while(cin >> a) solve();
    print(res);
}
0