結果
問題 | No.1262 グラフを作ろう! |
ユーザー | nok0 |
提出日時 | 2020-08-27 10:44:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 642 ms / 3,000 ms |
コード長 | 3,862 bytes |
コンパイル時間 | 3,472 ms |
コンパイル使用メモリ | 226,548 KB |
実行使用メモリ | 12,268 KB |
最終ジャッジ日時 | 2024-07-20 20:54:14 |
合計ジャッジ時間 | 37,776 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 402 ms
12,136 KB |
testcase_01 | AC | 279 ms
12,132 KB |
testcase_02 | AC | 463 ms
12,264 KB |
testcase_03 | AC | 377 ms
12,136 KB |
testcase_04 | AC | 43 ms
12,264 KB |
testcase_05 | AC | 219 ms
12,268 KB |
testcase_06 | AC | 30 ms
12,144 KB |
testcase_07 | AC | 52 ms
12,132 KB |
testcase_08 | AC | 306 ms
12,056 KB |
testcase_09 | AC | 244 ms
12,260 KB |
testcase_10 | AC | 191 ms
12,132 KB |
testcase_11 | AC | 308 ms
12,260 KB |
testcase_12 | AC | 388 ms
12,136 KB |
testcase_13 | AC | 375 ms
12,136 KB |
testcase_14 | AC | 154 ms
12,132 KB |
testcase_15 | AC | 203 ms
12,136 KB |
testcase_16 | AC | 270 ms
12,136 KB |
testcase_17 | AC | 294 ms
12,140 KB |
testcase_18 | AC | 440 ms
12,264 KB |
testcase_19 | AC | 55 ms
12,136 KB |
testcase_20 | AC | 179 ms
12,136 KB |
testcase_21 | AC | 518 ms
12,264 KB |
testcase_22 | AC | 30 ms
12,136 KB |
testcase_23 | AC | 240 ms
12,136 KB |
testcase_24 | AC | 324 ms
12,140 KB |
testcase_25 | AC | 48 ms
12,136 KB |
testcase_26 | AC | 87 ms
12,140 KB |
testcase_27 | AC | 187 ms
12,264 KB |
testcase_28 | AC | 162 ms
12,136 KB |
testcase_29 | AC | 109 ms
12,136 KB |
testcase_30 | AC | 147 ms
12,140 KB |
testcase_31 | AC | 486 ms
12,136 KB |
testcase_32 | AC | 244 ms
12,260 KB |
testcase_33 | AC | 113 ms
12,140 KB |
testcase_34 | AC | 250 ms
12,140 KB |
testcase_35 | AC | 384 ms
12,136 KB |
testcase_36 | AC | 133 ms
12,136 KB |
testcase_37 | AC | 507 ms
12,264 KB |
testcase_38 | AC | 258 ms
12,136 KB |
testcase_39 | AC | 231 ms
12,136 KB |
testcase_40 | AC | 214 ms
12,264 KB |
testcase_41 | AC | 138 ms
12,136 KB |
testcase_42 | AC | 413 ms
12,136 KB |
testcase_43 | AC | 188 ms
12,260 KB |
testcase_44 | AC | 214 ms
12,132 KB |
testcase_45 | AC | 369 ms
12,136 KB |
testcase_46 | AC | 97 ms
12,136 KB |
testcase_47 | AC | 267 ms
12,136 KB |
testcase_48 | AC | 352 ms
12,136 KB |
testcase_49 | AC | 480 ms
12,140 KB |
testcase_50 | AC | 408 ms
12,136 KB |
testcase_51 | AC | 297 ms
12,132 KB |
testcase_52 | AC | 128 ms
12,136 KB |
testcase_53 | AC | 74 ms
12,140 KB |
testcase_54 | AC | 444 ms
12,264 KB |
testcase_55 | AC | 320 ms
12,264 KB |
testcase_56 | AC | 135 ms
12,268 KB |
testcase_57 | AC | 541 ms
12,136 KB |
testcase_58 | AC | 387 ms
12,136 KB |
testcase_59 | AC | 125 ms
12,132 KB |
testcase_60 | AC | 529 ms
12,136 KB |
testcase_61 | AC | 176 ms
12,136 KB |
testcase_62 | AC | 445 ms
12,136 KB |
testcase_63 | AC | 434 ms
12,136 KB |
testcase_64 | AC | 262 ms
12,136 KB |
testcase_65 | AC | 75 ms
12,264 KB |
testcase_66 | AC | 196 ms
12,136 KB |
testcase_67 | AC | 141 ms
12,260 KB |
testcase_68 | AC | 86 ms
12,132 KB |
testcase_69 | AC | 147 ms
12,136 KB |
testcase_70 | AC | 381 ms
12,136 KB |
testcase_71 | AC | 310 ms
12,264 KB |
testcase_72 | AC | 465 ms
12,136 KB |
testcase_73 | AC | 552 ms
12,136 KB |
testcase_74 | AC | 342 ms
12,136 KB |
testcase_75 | AC | 366 ms
12,140 KB |
testcase_76 | AC | 274 ms
12,132 KB |
testcase_77 | AC | 354 ms
12,136 KB |
testcase_78 | AC | 388 ms
12,260 KB |
testcase_79 | AC | 520 ms
12,260 KB |
testcase_80 | AC | 348 ms
12,136 KB |
testcase_81 | AC | 349 ms
12,136 KB |
testcase_82 | AC | 445 ms
12,260 KB |
testcase_83 | AC | 337 ms
12,268 KB |
testcase_84 | AC | 317 ms
12,136 KB |
testcase_85 | AC | 563 ms
12,136 KB |
testcase_86 | AC | 410 ms
12,136 KB |
testcase_87 | AC | 523 ms
12,140 KB |
testcase_88 | AC | 336 ms
12,132 KB |
testcase_89 | AC | 314 ms
12,136 KB |
testcase_90 | AC | 169 ms
12,264 KB |
testcase_91 | AC | 170 ms
12,052 KB |
testcase_92 | AC | 168 ms
12,136 KB |
testcase_93 | AC | 482 ms
12,136 KB |
testcase_94 | AC | 642 ms
12,136 KB |
testcase_95 | AC | 386 ms
12,260 KB |
ソースコード
#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); }