結果

問題 No.1737 One to N
ユーザー akua
提出日時 2021-11-12 21:57:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 3,599 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 95,148 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 18:24:01
合計ジャッジ時間 1,591 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:24:15: warning: left shift count >= width of type [-Wshift-count-overflow]
   24 | const ll inf=1<<60;
      |              ~^~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;
const ll inf=1<<60;
//
const int MAX = 200005;
//
const int MOD = 1000000007;
const long long mod=1000000007;
const long long mod2=998244353;
using ll=long long;
using P= pair<ll, ll>;
ll fact[MAX], inv_fact[MAX], inv[MAX];
//
void init() {
// 1
fact[0] = 1;
fact[1] = 1;
inv[0] = 1;
inv[1] = 1;
inv_fact[0] = 1;
inv_fact[1] = 1;
//
repi(i, 2, MAX){
//
fact[i] = fact[i - 1] * i % MOD;
//
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//
inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;
}
}
//
ll nCk(int n, int k) {
ll x = fact[n]; // n!
ll y = inv_fact[n-k]; // (n-k)!
ll z = inv_fact[k]; // k!
if (n < k) return 0; //
if (n < 0 || k < 0) return 0; //
return x * ((y * z) % MOD) % MOD; //
}
struct UnionFind {
vector<int> par, siz;
UnionFind(int n) : par(n, -1) , siz(n, 1) { }
//
int root(int x) {
if (par[x] == -1) return x;
else return par[x] = root(par[x]);
}
// x y ()
bool issame(int x, int y) {
return root(x) == root(y);
}
// x y
bool unite(int x, int y) {
x = root(x), y = root(y);
if (x == y) return false;
if (siz[x] < siz[y]) swap(x, y);
par[y] = x;
siz[x] += siz[y];
return true;
}
// x
int size(int x) {
return siz[root(x)];
}
};
struct Edge
{
int to;
int w;
Edge(int to, int w) : to(to), w(w) { }
};
using Graph=vector<vector<int> >;
//min(x,y)0max(x,y)
//
ll gcd(ll x,ll y){
if(x<y) swap(x,y);
//x
ll r;
while(y>0){
r=x%y;
x=y;
y=r;
}
return x;
}
//
ll lcm(ll x,ll y){
return ll(x/gcd(x,y))*y;
}
ll pow_pow(ll x,ll n, ll mod){
if(n==0) return 1;
ll res=pow_pow(x*x/mod,n/2,mod);
if(n&1)res=res*x%mod;
return res;
}
int main(){
int n; cin >> n;
int ans=0;
int v=n;
if(n==1){
cout << 0 << endl;
return 0;
}
for(int i=2; i<=n; i++){
while(v%i==0){
v/=i;
ans+=i;
}
}
cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0