結果
問題 | No.278 連続する整数の和(2) |
ユーザー |
|
提出日時 | 2017-07-17 19:44:44 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 1,427 bytes |
コンパイル時間 | 1,423 ms |
コンパイル使用メモリ | 163,760 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 09:13:58 |
合計ジャッジ時間 | 2,152 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>#define ll long long#define INF 1000000005#define MOD 1000000007#define EPS 1e-10#define rep(i,n) for(int i=0;i<(int)n;++i)#define each(a, b) for(auto (a): (b))#define all(v) (v).begin(),(v).end()#define fi first#define se second#define pb push_back#define show(x) cout <<#x<<" = "<<(x)<<endl#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endlusing namespace std;typedef pair<int,int>P;const int MAX_N = 100005;vector<ll> dev;vector<int> id;void prime_factor(ll N){for(ll i=2;i*i<=N;i++){int cnt = 0;while(N%i == 0){cnt++;N /= i;}if(cnt){dev.pb(i);id.pb(cnt);}}if(N != 1){dev.pb(N);id.pb(1);}return;}int main(){ll n;cin >> n;if(n % 2){prime_factor(n);ll ans = 1;rep(i,id.size()){ll res = 0;rep(j,id[i]+1){res += (ll)pow(dev[i],j);}ans *= res;}cout << ans << endl;}else{prime_factor(n/2);ll ans = 1;rep(i,id.size()){ll res = 0;rep(j,id[i]+1){res += (ll)pow(dev[i],j);}ans *= res;}cout << ans << endl;}return 0;}