結果
問題 | No.864 四方演算 |
ユーザー |
![]() |
提出日時 | 2019-12-24 02:26:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 1,000 ms |
コード長 | 1,103 bytes |
コンパイル時間 | 1,882 ms |
コンパイル使用メモリ | 179,176 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-19 07:00:48 |
合計ジャッジ時間 | 2,741 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#pragma GCC optimize("Ofast")#include <bits/stdc++.h>using namespace std;typedef long long ll;#define EPS (1e-7)#define INF (1e9)#define rep(i, n) for(int i = 0; i < (int)(n); i++)#define all(x) x.begin(),x.end()const double PI = acos(-1);const ll MOD = 1000000007;template<class T>inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}template<class T>inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}///////////////////////////////////////////////////////////////int main() {ios::sync_with_stdio(false); cin.tie(nullptr);ll N,K; cin >> N >> K;vector<ll> A;for (ll i = 2; i*i <= K; i++) {if (K % i == 0) {if (i*i != K) {A.emplace_back(i);A.emplace_back(K/i);} else A.emplace_back(i);}}ll ans = 0;rep(i,A.size()) {if (A[i] > 2LL*N || K/A[i] > 2LL*N) continue;ll p = {A[i]-1 <= N ? A[i]-1LL : 2LL*N-A[i]+1};ll q = {K/A[i]-1 <= N ? K/A[i]-1LL : 2LL*N-K/A[i]+1LL};ans += p*q;}cout << ans << endl;}