結果

問題 No.1262 グラフを作ろう!
ユーザー nok0nok0
提出日時 2020-08-25 20:35:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 613 ms / 3,000 ms
コード長 3,761 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 209,024 KB
実行使用メモリ 12,072 KB
最終ジャッジ日時 2023-09-28 02:10:55
合計ジャッジ時間 29,714 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 310 ms
11,960 KB
testcase_01 AC 220 ms
11,912 KB
testcase_02 AC 331 ms
11,716 KB
testcase_03 AC 321 ms
11,844 KB
testcase_04 AC 31 ms
11,888 KB
testcase_05 AC 160 ms
11,848 KB
testcase_06 AC 22 ms
11,856 KB
testcase_07 AC 44 ms
11,888 KB
testcase_08 AC 204 ms
11,840 KB
testcase_09 AC 211 ms
11,980 KB
testcase_10 AC 156 ms
11,916 KB
testcase_11 AC 201 ms
11,960 KB
testcase_12 AC 302 ms
11,860 KB
testcase_13 AC 333 ms
11,836 KB
testcase_14 AC 134 ms
11,976 KB
testcase_15 AC 174 ms
11,976 KB
testcase_16 AC 218 ms
11,980 KB
testcase_17 AC 200 ms
12,040 KB
testcase_18 AC 319 ms
11,828 KB
testcase_19 AC 44 ms
11,964 KB
testcase_20 AC 115 ms
11,912 KB
testcase_21 AC 354 ms
11,836 KB
testcase_22 AC 22 ms
11,900 KB
testcase_23 AC 204 ms
11,832 KB
testcase_24 AC 232 ms
12,048 KB
testcase_25 AC 37 ms
11,716 KB
testcase_26 AC 68 ms
11,708 KB
testcase_27 AC 145 ms
11,852 KB
testcase_28 AC 123 ms
11,784 KB
testcase_29 AC 79 ms
11,976 KB
testcase_30 AC 111 ms
11,708 KB
testcase_31 AC 353 ms
11,784 KB
testcase_32 AC 203 ms
11,756 KB
testcase_33 AC 101 ms
11,976 KB
testcase_34 AC 170 ms
11,840 KB
testcase_35 AC 305 ms
11,748 KB
testcase_36 AC 118 ms
11,856 KB
testcase_37 AC 360 ms
11,708 KB
testcase_38 AC 181 ms
11,976 KB
testcase_39 AC 201 ms
11,960 KB
testcase_40 AC 163 ms
12,016 KB
testcase_41 AC 90 ms
11,844 KB
testcase_42 AC 296 ms
11,972 KB
testcase_43 AC 140 ms
11,780 KB
testcase_44 AC 175 ms
11,752 KB
testcase_45 AC 253 ms
11,780 KB
testcase_46 AC 68 ms
11,956 KB
testcase_47 AC 235 ms
11,780 KB
testcase_48 AC 235 ms
11,980 KB
testcase_49 AC 337 ms
11,852 KB
testcase_50 AC 260 ms
11,728 KB
testcase_51 AC 245 ms
11,724 KB
testcase_52 AC 82 ms
11,832 KB
testcase_53 AC 59 ms
11,712 KB
testcase_54 AC 334 ms
11,848 KB
testcase_55 AC 240 ms
11,892 KB
testcase_56 AC 95 ms
11,916 KB
testcase_57 AC 368 ms
11,900 KB
testcase_58 AC 325 ms
11,748 KB
testcase_59 AC 85 ms
12,008 KB
testcase_60 AC 334 ms
11,760 KB
testcase_61 AC 138 ms
11,712 KB
testcase_62 AC 322 ms
11,856 KB
testcase_63 AC 332 ms
11,984 KB
testcase_64 AC 204 ms
11,860 KB
testcase_65 AC 53 ms
11,732 KB
testcase_66 AC 141 ms
11,784 KB
testcase_67 AC 100 ms
11,900 KB
testcase_68 AC 56 ms
11,712 KB
testcase_69 AC 103 ms
11,908 KB
testcase_70 AC 243 ms
11,980 KB
testcase_71 AC 225 ms
11,892 KB
testcase_72 AC 297 ms
11,940 KB
testcase_73 AC 359 ms
11,752 KB
testcase_74 AC 307 ms
11,840 KB
testcase_75 AC 267 ms
12,072 KB
testcase_76 AC 207 ms
11,752 KB
testcase_77 AC 290 ms
12,048 KB
testcase_78 AC 251 ms
11,976 KB
testcase_79 AC 346 ms
11,976 KB
testcase_80 AC 223 ms
11,964 KB
testcase_81 AC 293 ms
11,788 KB
testcase_82 AC 356 ms
11,712 KB
testcase_83 AC 246 ms
12,032 KB
testcase_84 AC 222 ms
11,960 KB
testcase_85 AC 380 ms
11,900 KB
testcase_86 AC 284 ms
11,860 KB
testcase_87 AC 340 ms
11,752 KB
testcase_88 AC 301 ms
11,736 KB
testcase_89 AC 214 ms
11,968 KB
testcase_90 AC 158 ms
11,836 KB
testcase_91 AC 158 ms
11,856 KB
testcase_92 AC 162 ms
11,980 KB
testcase_93 AC 493 ms
11,784 KB
testcase_94 AC 613 ms
11,844 KB
testcase_95 AC 328 ms
11,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
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