結果
| 問題 |
No.2798 Multiple Chain
|
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2024-06-28 23:14:18 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,350 bytes |
| コンパイル時間 | 3,143 ms |
| コンパイル使用メモリ | 254,436 KB |
| 実行使用メモリ | 7,644 KB |
| 最終ジャッジ日時 | 2024-06-28 23:14:29 |
| 合計ジャッジ時間 | 6,779 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 WA * 2 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
// 存在しなければ -1 を return
long long _sqrt(long long x) {
if (x < 0)return -1;
long long ng = -1;
long long ok = 3 * (long long)INF + 1;
while (1 < abs(ok - ng)) {
long long c = (ng + ok) / 2;
auto check = [&]() {
return x <= c * c;
};
if (check()) ok = c;
else ng = c;
}
long long ret = ok;
if (ret * ret != x)ret = -1;
return ret;
}
std::vector<long long> sieveOfEratosthenes(long long n = 1000000) {
std::vector<bool>p(n + 1, true);
std::vector<long long>ret;
p[0] = false;
p[1] = false;
for (int i = 2; i <= n; ++i) {
if (!p[i]) continue;
ret.push_back(i);
for (int j = 2 * i; j <= n; j += i) p[j] = false;
}
return ret;
}
void solve(long long n) {
auto pv = sieveOfEratosthenes();
set<long long>st;
for (auto p : pv)st.insert(p);
long long ans = 1;
vector<long long>devide = { 1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490, 627, 792, 1002, 1255, 1575, 1958, 2436, 3010, 3718, 4565, 5604, 6842, 8349, 10143, 12310 };
for (long long i = 1; i < 1000001; ++i) {
if (0 != n % i)continue;
// n = p^2 * q
// i = min(p,q)
long long p = -1;
if (st.count(i) && 0 == n % (i * i)) {
p = i;
}
else {
auto p = _sqrt(n / i);
}
if (-1 == p)continue;
int cnt = 0;
long long cn = n;
while (0 == cn % i) {
cnt++;
cn /= i;
}
//cout << p << " " << cnt << endl;
ans *= devide[cnt];
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n; cin >> n;
solve(n);
return 0;
}
kwm_t