結果

問題 No.278 連続する整数の和(2)
ユーザー tottoripaper
提出日時 2015-09-28 22:10:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 431 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 54,440 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 09:07:19
合計ジャッジ時間 998 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%lld", &N);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <iostream>

typedef long long ll;

int main(){
    ll N;
    scanf("%lld", &N);

    if(N % 2 == 0){N >>= 1;}
    
    ll res = 1ll;
    
    for(ll i=2;i*i<=N;i++){
        ll productSum = 1ll, product = 1ll;
        while(N % i == 0){
            product *= i;
            productSum += product;
            N /= i;
        }

        res *= productSum;
    }

    if(N > 1){res *= 1 + N;}

    printf("%lld\n", res);
}
0