結果

問題 No.888 約数の総和
ユーザー tarattata1tarattata1
提出日時 2019-09-20 22:30:46
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,667 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 78,436 KB
実行使用メモリ 7,252 KB
最終ジャッジ日時 2024-09-14 18:25:12
合計ジャッジ時間 2,245 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:67:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   67 |     scanf("%lld", &n);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

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

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;
vector<int> pp;
void preparePrime( int maxp )
{
int i;
vector<int> a(maxp+1);
for(i=2; i<=maxp; i++) {
int k=i+i;
while(k<=maxp) {
a[k]=1;
k+=i;
}
}
for(i=2; i<=maxp; i++) {
if(a[i]==0) pp.push_back( i );
}
return;
}
void decompositPrime( ll a, vector<pair<ll,ll> >& vv )
{
preparePrime( (int)sqrt((double)a)+1 );
int i;
for(i=0; i<(int)pp.size(); i++) {
int count = 0;
while(a % pp[i] == 0 ) {
a /= pp[i];
count ++;
}
if(count>0) vv.push_back( make_pair( pp[i], count ) );
if (a==1) break;
}
if(a>1) {
vv.push_back( make_pair( a, 1 ) );
}
return;
}
int main(int argc, char* argv[])
{
ll n;
scanf("%lld", &n);
vector<pair<ll,ll> > vv;
decompositPrime( n, vv );
int siz=(int)vv.size();
int i, k;
ll ans=1;
for(i=0; i<siz; i++) {
ll sum=0;
ll curr=1;
for(k=0; k<=vv[i].second; k++) {
if(k>0) curr*=vv[i].first;
sum += curr;
}
ans *= sum;
}
printf("%lld\n", ans);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0