結果
問題 | No.278 連続する整数の和(2) |
ユーザー |
|
提出日時 | 2020-02-22 08:12:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 346 bytes |
コンパイル時間 | 488 ms |
コンパイル使用メモリ | 64,280 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-09 15:54:23 |
合計ジャッジ時間 | 1,384 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
コンパイルメッセージ
main.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 14 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; long X,ans; long gcd(long a,long b){return b?gcd(b,a%b):a;} bool f(long d) { long L=d-1,R=X; if(L%2==0)L/=2; else R/=2; long g=gcd(L,d); d/=g; return R%d==0; } main() { cin>>X; for(long i=1;i*i<=X;i++) { if(X%i==0) { if(f(i))ans+=i; if(i<X/i&&f(X/i))ans+=X/i; } } cout<<ans<<endl; }