結果
| 問題 | No.3364 Push_back Operation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-16 15:24:06 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 91 ms / 2,000 ms |
| + 377µs | |
| コード長 | 1,964 bytes |
| 記録 | |
| コンパイル時間 | 3,305 ms |
| コンパイル使用メモリ | 177,328 KB |
| 実行使用メモリ | 9,776 KB |
| 最終ジャッジ日時 | 2026-10-16 15:24:18 |
| 合計ジャッジ時間 | 8,988 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 53 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
const ll MOD=998244353;
struct mint{
ll val;
mint(ll val_=0):val(val_%MOD){
if(val<0) val+=MOD;
}
mint operator-()const{
return mint(-val);
}
mint& operator+=(const mint& other){
val+=other.val;
if(val>=MOD) val-=MOD;
return *this;
}
mint& operator-=(const mint& other){
val-=other.val;
if(val<0) val+=MOD;
return *this;
}
mint& operator*=(const mint& other){
val*=other.val, val%=MOD;
return *this;
}
mint pow(ll n) const{
mint ans(1);
mint mul(*this);
while(n){
if(n&1) ans*=mul;
mul*=mul;
n/=2;
}
return ans;
}
mint inv() const{
return pow(MOD-2);
}
mint& operator/=(const mint& other){
return *this*=other.inv();
}
friend bool operator==(const mint& lhs, const mint& rhs){
return lhs.val == rhs.val;
}
friend bool operator!=(const mint& lhs, const mint& rhs){
return lhs.val != rhs.val;
}
friend mint operator+(mint lhs, const mint& rhs) {
lhs+=rhs;
return lhs;
}
friend mint operator-(mint lhs, const mint& rhs) {
lhs-=rhs;
return lhs;
}
friend mint operator*(mint lhs, const mint& rhs) {
lhs*=rhs;
return lhs;
}
friend mint operator/(mint lhs, const mint& rhs) {
lhs/=rhs;
return lhs;
}
friend istream& operator>>(istream& is, mint& m) {
ll x;
is >> x;
m=mint(x);
return is;
}
friend ostream& operator<<(ostream& os, const mint& m) {
return os << m.val;
}
};
int main(void){
ll n; cin >> n;
ll last=n+1;
mint ans=0;
for(ll i=1; i*i<=n; i++){
ll x=n/i;
ans+=mint(x).pow(i);
last=i;
}
last++;
for(ll i=last; i<=n;){
ll x=n/i, r=n/x;
if(x==1) ans+=r-i+1;
else{
mint a0=mint(x).pow(i);
ans+=a0*(mint(1)-mint(x).pow(r-i+1))/(mint(1)-x);
}
i=r+1;
}
cout << ans << endl;
return 0;
}