結果
| 問題 | No.3651 K-th Sum of Divisors |
| コンテスト | |
| ユーザー |
👑 potato167
|
| 提出日時 | 2026-08-28 21:29:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| + 925µs | |
| コード長 | 5,447 bytes |
| 記録 | |
| コンパイル時間 | 2,398 ms |
| コンパイル使用メモリ | 220,348 KB |
| 実行使用メモリ | 27,648 KB |
| 最終ジャッジ日時 | 2026-08-28 21:30:24 |
| 合計ジャッジ時間 | 4,935 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
コンパイルメッセージ
/Users/Shared/po167_library/ds/Doubling.hpp:52:50: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' [-Wc++20-extensions]
ソースコード
#line 1 "e.cpp"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll ILL=2167167167167167167;
const int INF=2100000000;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define all(p) p.begin(),p.end()
template<class T> using pq_ = priority_queue<T, vector<T>, greater<T>>;
template<class T> int LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> int UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,T b){if(b<a){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
bool yneos(bool a,bool upp=false){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;}
template<class T> void vec_out(vector<T> &p,int ty=0){
if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'<<p[i]<<'"';}cout<<"}\n";}
else{if(ty==1){cout<<p.size()<<"\n";}for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}}
template<class T> T vec_min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T vec_max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}
template<class T> T vec_sum(vector<T> &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;}
int pop_count(long long a){int res=0;while(a){res+=(int)(a&1),a>>=1;}return res;}
template<class T> T square(T a){return a * a;}
//Nの正の約数を列挙する
vector<long long> Divisors(long long N){
vector<long long> p,q;
long long i=1,K=0;
while(i*i<N){
if(N%i==0){
p.push_back(i);
q.push_back(N/i);
K++;
}
i++;
}
if(i*i==N) p.push_back(i);
for(int i=K-1;i>=0;i--){
p.push_back(q[i]);
}
return p;
}
#line 4 "/Users/Shared/po167_library/ds/Doubling.hpp"
namespace po167{
template<class T, T(*op)(T, T)>
struct Doubling_op{
struct result{
long long times;
int ind;
T val;
};
int n;
int depth;
std::vector<std::vector<int>> index;
std::vector<std::vector<T>> val;
Doubling_op(std::vector<int> p, std::vector<T> v, long long lim = (1ll << 60) - 1){
n = p.size();
for (auto x : p) assert(0 <= x && x < n);
assert(n == (int)v.size());
depth = 1;
while ((1ll << depth) <= lim) depth++;
index.resize(depth);
val.resize(depth);
index[0] = p;
val[0] = v;
for (int i = 1; i < depth; i++){
index[i].resize(n);
val[i].resize(n);
for (int j = 0; j < n; j++){
int tmp = index[i - 1][j];
index[i][j] = index[i - 1][tmp];
val[i][j] = op(val[i - 1][j], val[i - 1][tmp]);
}
}
}
result query(int start_ind, T start_val, long long times){
assert(0 <= start_ind && start_ind < n);
assert(0 <= times && times < (1ll << depth));
int i = 0;
long long TIMES = times;
while (times){
if (times & 1){
start_val = op(start_val, val[i][start_ind]);
start_ind = index[i][start_ind];
}
i++;
times >>= 1;
}
return {TIMES, start_ind, start_val};
}
result max_right(int start_ind, T start_val, auto f){
if (!f(start_val)) return {-1, start_ind, start_val};
long long times = 0;
for (int d = depth - 1; d >= 0; d--){
if (f(op(start_val, val[d][start_ind]))){
start_val = op(start_val, val[d][start_ind]);
start_ind = index[d][start_ind];
times += (1ll << d);
}
}
return {times, start_ind, start_val};
}
};
struct Doubling{
int n;
int depth;
std::vector<std::vector<int>> index;
Doubling(std::vector<int> p, long long lim = (1ll << 60) - 1){
n = p.size();
for (auto x : p) assert(0 <= x && x < n);
depth = 1;
while ((1ll << depth) <= lim) depth++;
index.resize(depth);
index[0] = p;
for (int i = 1; i < depth; i++){
index[i].resize(n);
for (int j = 0; j < n; j++){
index[i][j] = index[i - 1][index[i - 1][j]];
}
}
}
int query(int ind, long long times){
assert(0 <= ind && ind < n);
assert(0 <= times && times < (1ll << depth));
int i = 0;
while (times){
if (times & 1) ind = index[i][ind];
i++;
times >>= 1;
}
return ind;
}
};
}
#line 46 "e.cpp"
void solve();
// DEAR MYSTERIES / TOMOO
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
rep(i, 0, t) solve();
}
void solve(){
const int P = 100'003;
vector<int> to(P);
rep(i, 1, P) {
for (int j = i; j < P; j += i) {
to[j] = (to[j] + i) % P;
}
}
po167::Doubling D(to);
ll N, K;
cin >> N >> K;
auto tmp = Divisors(N);
ll st = vec_sum(tmp) % P;
if (K == 1) {
cout << N << "\n";
}
else {
cout << D.query(st, K - 2) << "\n";
}
}
potato167