結果

問題 No.864 四方演算
ユーザー siro53siro53
提出日時 2019-08-16 21:59:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,109 bytes
コンパイル時間 2,099 ms
コンパイル使用メモリ 187,224 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-23 23:15:55
合計ジャッジ時間 4,695 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0