結果
| 問題 | No.3505 Sum of Prod of Root |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-19 18:19:37 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,308 bytes |
| 記録 | |
| コンパイル時間 | 5,969 ms |
| コンパイル使用メモリ | 374,844 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-19 18:20:28 |
| 合計ジャッジ時間 | 15,030 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | WA * 2 TLE * 1 -- * 10 |
ソースコード
// Compile: g++ -std=c++20 -O2 -Wall -I$HOME/ctf/tools/ac-library -DLOCAL -o sol sol.cpp
// Or: make sol (uses Makefile in this dir)
// Run: ./sol < in.txt
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);++i)
#define rep2(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((ll)(x).size())
template<class T> bool chmin(T&a,const T&b){if(b<a){a=b;return true;}return false;}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
#ifdef LOCAL
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#else
#define dbg(x)
#endif
using mint = modint998244353;
// using mint = modint1000000007;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
mint ans = 0;
// k=1
mint p_sum = (mint)n * (n + 1) / 2;
ans += p_sum;
// cout << "p_sum: "<< ans.val() << endl;
// k>1
for (ll k = 2; (ll)(pow((long double)n, (long double)1.0/(long double)k)) > 1; k++) {
ans += ((ll)floor(pow((long double)n, (long double)1.0 / (long double)k))-1) * p_sum;
// cout << "k=" << k << ": "<< ans.val() << endl;
}
mint k2_sub = 0;
for (ll q = 1; (ll)(pow((long double)n, (long double)1.0 / (long double)2.0)) >= q + 1; q++) {
k2_sub += (mint)q * (q + 2) * (q + 1) * (q + 1) / 2;
// cout << "q=" << q << ": "<<k2_sub.val() << endl;
}
ans -= k2_sub;
// vector<ll> store(n+1);
// for (ll i = 1; i <= n; i++) {
// mint now = 1;
// cout << "i=" << i << ", valid_k= ";
// for (ll k = 1; k <= 20000; k++) {
// now *= (ll)(pow((long double)i, (long double)1.0/(long double)k));
// if((ll)(pow(i, 1.0/k))>1) cout << k << ", ";
// }
// cout << " -> now=" << now.val();
// ans += now;
// store[i] = now.val();
// cout << ", diff=" << store[i] - store[i - 1] << endl;
// }
cout << ans.val() << endl;
return 0;
}