結果
| 問題 |
No.864 四方演算
|
| ユーザー |
e869120
|
| 提出日時 | 2019-08-16 14:24:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 1,000 ms |
| コード長 | 746 bytes |
| コンパイル時間 | 1,136 ms |
| コンパイル使用メモリ | 82,368 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 10:41:53 |
| 合計ジャッジ時間 | 2,361 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cassert>
using namespace std;
long long N, K, sum;
vector<pair<long long, long long>> E;
long long check(long long pos) {
if (pos <= 1 || pos > 2LL * N) return 0LL;
return N - abs(N + 1LL - pos);
}
int main() {
cin >> N >> K;
assert(1LL <= N && N <= 1000000000000LL);
assert(1LL <= K && K <= 1000000000000LL);
for (long long i = 1; i*i <= K; i++) {
if (K%i != 0) continue;
E.push_back(make_pair(i, K / i));
E.push_back(make_pair(K / i, i));
}
sort(E.begin(), E.end());
E.erase(unique(E.begin(), E.end()), E.end());
for (int i = 0; i < E.size(); i++) {
sum += check(E[i].first) * check(E[i].second);
}
cout << sum << endl;
return 0;
}
e869120