結果

問題 No.278 連続する整数の和(2)
ユーザー Lay_ecLay_ec
提出日時 2015-09-05 00:13:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 806 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 74,136 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 07:29:41
合計ジャッジ時間 1,413 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 13 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 6 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

long long calc(long long x){
    long long res=1;
    for(long long i=2;i*i<=x;i++){
        if(x%i) continue;
        long long tmp=i;
        while(x%tmp==0){
            x/=i; tmp*=i;
        }
        //(1+i^1+i^2+...+i^(n-1))=(i^n)/(i-1)
        //tmp=i^n
        res*=(tmp-1)/(i-1);
    }
    
    //残ったxは素数
    if(x!=1){
        res*=(1+x);
    }
    
    return res;
}

int main()
{

    long long n;
    cin>>n;
    
    long long x;
    if(n%2) x=n;
    else x=n/2;

    cout<<calc(x)<<endl;

    return 0;
}
0