結果
| 問題 |
No.864 四方演算
|
| ユーザー |
|
| 提出日時 | 2019-08-16 21:59:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,109 bytes |
| コンパイル時間 | 2,042 ms |
| コンパイル使用メモリ | 187,656 KB |
| 実行使用メモリ | 13,768 KB |
| 最終ジャッジ日時 | 2024-09-22 16:28:22 |
| 合計ジャッジ時間 | 4,583 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | WA * 1 TLE * 1 -- * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
if (a < b)
{
a = b;
return 1;
}
return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
if (a > b)
{
a = b;
return 1;
}
return 0;
}
typedef long long int ll;
#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//-------------------------------------
vector<ll> divisor(ll n)
{
vector<ll> ret;
for (ll i = 1; i * i <= n; i++)
{
if (n % i == 0)
{
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
ll n, k;
cin >> n >> k;
auto yakusu = divisor(k);
ll m = yakusu.size();
set<string> st;
for (ll i = 1; i < (m / 2); i++)
{
ll ac = yakusu[i];
ll bd = yakusu[m - i - 1];
for (ll j = 1; j < ac; j++)
{
for (ll k = 1; k < bd; k++)
{
vector<string> rec = {to_string(j), to_string(ac - j), to_string(k), to_string(bd - k)};
bool flg = false;
for (auto tmp : rec)
{
if (stoll(tmp) > n)
{
flg = true;
}
}
if (flg)
{
continue;
}
st.insert(rec[0] + rec[1] + rec[2] + rec[3]);
st.insert(rec[1] + rec[0] + rec[2] + rec[3]);
st.insert(rec[0] + rec[1] + rec[3] + rec[2]);
st.insert(rec[1] + rec[0] + rec[3] + rec[2]);
}
}
}
// for (auto tmp : st)
// {
// cout << tmp << endl;
// }
cout << (ll)st.size() * 2LL << endl;
}