結果

問題 No.1262 グラフを作ろう!
ユーザー nok0nok0
提出日時 2020-08-25 20:33:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 569 ms / 3,000 ms
コード長 3,746 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 210,996 KB
実行使用メモリ 12,044 KB
最終ジャッジ日時 2023-09-28 02:11:47
合計ジャッジ時間 28,127 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 301 ms
11,832 KB
testcase_01 AC 203 ms
11,780 KB
testcase_02 AC 306 ms
11,924 KB
testcase_03 AC 306 ms
11,724 KB
testcase_04 AC 32 ms
11,832 KB
testcase_05 AC 155 ms
11,776 KB
testcase_06 AC 20 ms
11,776 KB
testcase_07 AC 40 ms
11,776 KB
testcase_08 AC 197 ms
11,860 KB
testcase_09 AC 206 ms
11,716 KB
testcase_10 AC 153 ms
11,988 KB
testcase_11 AC 207 ms
11,952 KB
testcase_12 AC 278 ms
11,724 KB
testcase_13 AC 297 ms
11,860 KB
testcase_14 AC 125 ms
11,956 KB
testcase_15 AC 168 ms
12,028 KB
testcase_16 AC 211 ms
11,716 KB
testcase_17 AC 203 ms
11,936 KB
testcase_18 AC 322 ms
11,720 KB
testcase_19 AC 40 ms
12,000 KB
testcase_20 AC 103 ms
11,912 KB
testcase_21 AC 335 ms
11,724 KB
testcase_22 AC 19 ms
11,992 KB
testcase_23 AC 189 ms
11,956 KB
testcase_24 AC 216 ms
11,724 KB
testcase_25 AC 33 ms
11,984 KB
testcase_26 AC 59 ms
11,892 KB
testcase_27 AC 131 ms
11,888 KB
testcase_28 AC 114 ms
11,728 KB
testcase_29 AC 73 ms
11,776 KB
testcase_30 AC 99 ms
12,020 KB
testcase_31 AC 334 ms
11,780 KB
testcase_32 AC 186 ms
11,956 KB
testcase_33 AC 96 ms
11,776 KB
testcase_34 AC 158 ms
11,940 KB
testcase_35 AC 278 ms
11,776 KB
testcase_36 AC 109 ms
12,044 KB
testcase_37 AC 344 ms
11,724 KB
testcase_38 AC 183 ms
11,992 KB
testcase_39 AC 187 ms
11,836 KB
testcase_40 AC 158 ms
11,972 KB
testcase_41 AC 96 ms
11,968 KB
testcase_42 AC 275 ms
11,864 KB
testcase_43 AC 133 ms
11,844 KB
testcase_44 AC 164 ms
11,884 KB
testcase_45 AC 244 ms
11,732 KB
testcase_46 AC 65 ms
11,836 KB
testcase_47 AC 230 ms
11,780 KB
testcase_48 AC 241 ms
12,044 KB
testcase_49 AC 336 ms
12,044 KB
testcase_50 AC 276 ms
11,976 KB
testcase_51 AC 240 ms
11,724 KB
testcase_52 AC 85 ms
11,840 KB
testcase_53 AC 58 ms
11,888 KB
testcase_54 AC 329 ms
11,908 KB
testcase_55 AC 227 ms
11,840 KB
testcase_56 AC 92 ms
11,892 KB
testcase_57 AC 370 ms
11,724 KB
testcase_58 AC 285 ms
11,784 KB
testcase_59 AC 81 ms
11,772 KB
testcase_60 AC 339 ms
11,864 KB
testcase_61 AC 133 ms
11,908 KB
testcase_62 AC 303 ms
11,720 KB
testcase_63 AC 321 ms
11,728 KB
testcase_64 AC 207 ms
11,992 KB
testcase_65 AC 51 ms
11,976 KB
testcase_66 AC 137 ms
11,952 KB
testcase_67 AC 90 ms
11,840 KB
testcase_68 AC 55 ms
11,956 KB
testcase_69 AC 97 ms
11,884 KB
testcase_70 AC 234 ms
11,868 KB
testcase_71 AC 209 ms
11,968 KB
testcase_72 AC 279 ms
11,772 KB
testcase_73 AC 387 ms
11,908 KB
testcase_74 AC 287 ms
11,944 KB
testcase_75 AC 247 ms
11,780 KB
testcase_76 AC 198 ms
11,912 KB
testcase_77 AC 279 ms
11,720 KB
testcase_78 AC 240 ms
11,776 KB
testcase_79 AC 319 ms
11,892 KB
testcase_80 AC 237 ms
11,840 KB
testcase_81 AC 275 ms
11,776 KB
testcase_82 AC 344 ms
12,016 KB
testcase_83 AC 225 ms
11,936 KB
testcase_84 AC 209 ms
11,912 KB
testcase_85 AC 350 ms
11,728 KB
testcase_86 AC 276 ms
11,728 KB
testcase_87 AC 321 ms
11,724 KB
testcase_88 AC 274 ms
11,956 KB
testcase_89 AC 200 ms
11,836 KB
testcase_90 AC 142 ms
11,776 KB
testcase_91 AC 142 ms
11,728 KB
testcase_92 AC 143 ms
11,972 KB
testcase_93 AC 471 ms
11,716 KB
testcase_94 AC 569 ms
11,728 KB
testcase_95 AC 327 ms
11,992 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 mt{
    mt(){
        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];
            }
        }
    }
}mt_;

ll res;
map<int, int> mp;
void solve(){
    INT(a);
    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(m--) solve();
    print(res);
}
0