結果
問題 | No.1276 3枚のカード |
ユーザー | 🍮かんプリン |
提出日時 | 2020-11-03 19:25:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,521 ms / 2,000 ms |
コード長 | 3,416 bytes |
コンパイル時間 | 2,701 ms |
コンパイル使用メモリ | 173,736 KB |
実行使用メモリ | 9,832 KB |
最終ジャッジ日時 | 2023-09-29 14:57:49 |
合計ジャッジ時間 | 48,258 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1,285 ms
8,868 KB |
testcase_11 | AC | 605 ms
6,160 KB |
testcase_12 | AC | 769 ms
6,536 KB |
testcase_13 | AC | 806 ms
6,688 KB |
testcase_14 | AC | 72 ms
4,380 KB |
testcase_15 | AC | 650 ms
6,372 KB |
testcase_16 | AC | 1,407 ms
9,100 KB |
testcase_17 | AC | 751 ms
6,484 KB |
testcase_18 | AC | 568 ms
6,140 KB |
testcase_19 | AC | 926 ms
6,632 KB |
testcase_20 | AC | 539 ms
6,224 KB |
testcase_21 | AC | 562 ms
6,272 KB |
testcase_22 | AC | 1,426 ms
9,180 KB |
testcase_23 | AC | 63 ms
4,376 KB |
testcase_24 | AC | 878 ms
6,784 KB |
testcase_25 | AC | 291 ms
4,780 KB |
testcase_26 | AC | 1,091 ms
8,532 KB |
testcase_27 | AC | 1,247 ms
9,092 KB |
testcase_28 | AC | 1,202 ms
8,952 KB |
testcase_29 | AC | 685 ms
6,492 KB |
testcase_30 | AC | 131 ms
4,568 KB |
testcase_31 | AC | 58 ms
4,376 KB |
testcase_32 | AC | 313 ms
4,780 KB |
testcase_33 | AC | 19 ms
4,380 KB |
testcase_34 | AC | 215 ms
4,568 KB |
testcase_35 | AC | 202 ms
4,624 KB |
testcase_36 | AC | 12 ms
4,376 KB |
testcase_37 | AC | 189 ms
4,520 KB |
testcase_38 | AC | 124 ms
4,380 KB |
testcase_39 | AC | 328 ms
4,824 KB |
testcase_40 | AC | 1,361 ms
9,176 KB |
testcase_41 | AC | 1,122 ms
9,064 KB |
testcase_42 | AC | 1,216 ms
9,524 KB |
testcase_43 | AC | 1,058 ms
9,516 KB |
testcase_44 | AC | 1,509 ms
9,792 KB |
testcase_45 | AC | 1,366 ms
9,372 KB |
testcase_46 | AC | 1,365 ms
9,832 KB |
testcase_47 | AC | 1,121 ms
8,728 KB |
testcase_48 | AC | 1,078 ms
9,828 KB |
testcase_49 | AC | 1,222 ms
9,068 KB |
testcase_50 | AC | 1,351 ms
9,088 KB |
testcase_51 | AC | 1,164 ms
9,200 KB |
testcase_52 | AC | 994 ms
8,792 KB |
testcase_53 | AC | 1,169 ms
9,352 KB |
testcase_54 | AC | 1,348 ms
9,104 KB |
testcase_55 | AC | 1,036 ms
9,320 KB |
testcase_56 | AC | 1,003 ms
9,308 KB |
testcase_57 | AC | 1,289 ms
9,784 KB |
testcase_58 | AC | 1,344 ms
9,048 KB |
testcase_59 | AC | 1,171 ms
8,984 KB |
testcase_60 | AC | 1,521 ms
9,260 KB |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2020.11.03 19:24:46 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; template < int MOD > struct mint { public: long long x; mint(long long x = 0) : x((x % MOD + MOD) % MOD) {} mint(std::string& s) { long long z = 0; for (int i = 0; i < s.size(); i++) { z *= 10; z += s[i] - '0'; z %= MOD; } this->x = z; } mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint& a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; } mint& operator/=(const mint& a) { long long n = MOD - 2; mint u = 1, b = a; while (n > 0) { if (n & 1) { u *= b; } b *= b; n >>= 1; } return *this *= u; } mint operator+(const mint& a) const { mint res(*this); return res += a; } mint operator-() const { return mint() -= *this; } mint operator-(const mint& a) const { mint res(*this); return res -= a; } mint operator*(const mint& a) const { mint res(*this); return res *= a; } mint operator/(const mint& a) const { mint res(*this); return res /= a; } friend std::ostream& operator<<(std::ostream& os, const mint& n) { return os << n.x; } friend std::istream& operator>>(std::istream& is, mint& n) { long long x; is >> x; n = mint(x); return is; } bool operator==(const mint& a) const { return this->x == a.x; } bool operator!=(const mint& a) const { return this->x != a.x; } mint pow(long long k) const { mint ret = 1; mint p = this->x; while (k > 0) { if (k & 1) { ret *= p; } p *= p; k >>= 1; } return ret; } }; constexpr int MOD = 1e9 + 7; template < typename T > vector< pair< pair< T, T >, T > > quotient_range(T N) { T M; vector< pair< pair< T, T >, T > > ret; for (M = 1; M * M <= N; M++) { ret.emplace_back(make_pair(M, M), N / M); } for (T i = M; i >= 1; i--) { T L = N / (i + 1) + 1; T R = N / i; if (L <= R && ret.back().first.second < L) ret.emplace_back(make_pair(L, R), N / L); } return ret; } mint< MOD > floor_sum(ll N) { auto v = quotient_range(N); mint< MOD > ans = 0; for (auto p : v) { ans += mint< MOD >(p.second) * (p.first.second - p.first.first + 1); } return ans; } mint< MOD > floor_sum2(ll N) { auto v = quotient_range(N); mint< MOD > ans = 0; for (auto p : v) { ans += mint< MOD >(p.second) * p.second * (p.first.second - p.first.first + 1); } return ans; } int main() { int n; cin >> n; mint< MOD > ans = 0; ans += floor_sum(n) - n; ans *= n - 2; ans -= floor_sum2(n) - floor_sum(n) * 3 + 2 * n; for (auto p : quotient_range(n)) { ans -= (floor_sum(p.second) - p.second * 2 + 1) * (p.first.second - p.first.first + 1); } cout << ans << endl; return 0; }