結果

問題 No.864 四方演算
ユーザー caobicaobi
提出日時 2021-05-29 21:39:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 2,356 bytes
コンパイル時間 1,491 ms
コンパイル使用メモリ 166,592 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 23:54:15
合計ジャッジ時間 3,113 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 13 ms
4,380 KB
testcase_02 AC 9 ms
4,384 KB
testcase_03 AC 9 ms
4,380 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 11 ms
4,376 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 9 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 9 ms
4,380 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 8 ms
4,376 KB
testcase_20 AC 11 ms
4,376 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 8 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 8 ms
4,380 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define rng(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i)
#define per(i, b) gnr(i, 0, b)
#define all(obj) begin(obj), end(obj)
#define allr(obj) rbegin(obj), rend(obj)
#define cinv(a) rep(i, (int)a.size()) cin >> a[i]
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<Pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};
const int MOD =	1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const long double eps = 1e-10;
const char nl = '\n';

ll power(ll a, ll b) { return b ? power(a * a % MOD, b / 2) * (b % 2 ? a : 1) % MOD : 1; }

ll nCk(int n, int k)
{
	ll x = 1, y = 1;
	for (int i = 1; i <= k; ++i)
	{
		x = x * (n - i + 1) % MOD;
		y = y * i % MOD;
	}
	return x * power(y, MOD - 2) % MOD;
}

struct UF
{
	vi d;
	UF(int n) : d(n, -1) {}
	int root(int x)
	{
		if (d[x] < 0)
			return x;
		return d[x] = root(d[x]);
	}
	bool unite(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -d[root(x)]; }
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(20);	
	ll n, k; cin >> n >> k;	
	ll ans = 0;
	auto f = [&](ll x) -> ll
	{
		if (x <= n+1) return x-1;
		else if (x > 2*n) return 0;
		else 
		{
			ll y = x - 1 - 2*(x-1-n);
			return y < 0 ? 0 : y;
		}
	};
	for (ll i = 2; i*i <= k; ++i)
		if (k % i == 0)
		{
			if (i*i == k) ans += f(i)*f(i);
			else ans += 2*f(i)*f(k/i);
		}

	cout << ans << nl;
}	
	
0