結果
問題 |
No.276 連続する整数の和(1)
|
ユーザー |
![]() |
提出日時 | 2015-09-04 22:40:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,021 bytes |
コンパイル時間 | 787 ms |
コンパイル使用メモリ | 89,576 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-19 01:11:21 |
合計ジャッジ時間 | 1,225 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cctype> #include<cstdlib> #include<algorithm> #include<bitset> #include<vector> #include<list> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<sstream> #include<fstream> #include<iomanip> #include<ctime> #include<complex> #include<functional> #include<climits> #include<cassert> #include<iterator> using namespace std; int n; long long int sum(long long int a, long long int b){ long long int k = a + b - 1LL; return (a + k)*b / 2LL; } long long int __gcd(long long int a, long long int b){ if (a > b){ swap(a, b); } while (a){ b %= a; swap(a, b); } return b; } int main(){ scanf("%d", &n); long long int s = sum(1, n); long long int ss = sum(1 + 1LL, n); ss = __gcd(s, ss); long long int ind = 1LL; long long int ans = 0; while (ind*ind <= ss){ if (ss%ind == 0LL){ ans += ind; } ind++; } if (ind < ss){ ans += ind; } printf("%lld\n", ans); return 0; }