結果
| 問題 |
No.2880 Max Sigma Mod
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2024-09-12 16:34:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,431 bytes |
| コンパイル時間 | 2,232 ms |
| コンパイル使用メモリ | 201,892 KB |
| 最終ジャッジ日時 | 2025-02-24 06:45:56 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 35 WA * 13 |
ソースコード
#include <bits/stdc++.h>
using ll = std::int64_t;
int main(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int N, M;
std::cin >> N >> M;
int L = std::max(N, M);
std::vector<int> spf(L + 1, 0), primes;
for(int i=2;i<=L;i++){
if(spf[i] == 0){
spf[i] = i;
primes.emplace_back(i);
}
for(int p : primes){
if(p > spf[i] || !(i <= M / p)){break;}
spf[i * p] = p;
}
}
ll res = 0;
ll now = 0;
for(int i=1;i<=N;i++){
std::vector<std::tuple<int, int>> factors;
{
int x = i;
while(x > 1){
int p = spf[x];
int t = 0;
while(x % p == 0){
x /= p;
t += 1;
}
factors.emplace_back(p, t);
}
}
std::vector<int> divisors{1};
for(auto &[p, t] : factors){
int l = divisors.size();
divisors.resize(l * (t + 1));
for(int i=l;i<l*(t+1);i++){
divisors[i] = divisors[i - l] * p;
}
}
int count = 0;
for(int d : divisors){
if(d <= M){
now -= d - 1;
count += 1;
}
}
now += M - count;
res = std::max(res, now);
}
std::cout << res << std::endl;
}
tottoripaper