結果

問題 No.864 四方演算
ユーザー roundplusroundplus
提出日時 2019-10-03 17:42:39
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 2,853 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 105,348 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 13:01:41
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

template<typename T>
vector<T> DIVISOR(T n) {
    vector<T> v;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            v.push_back(i);
            if (i != n / i) {
                v.push_back(n / i);
            }
        }
    }
    sort(v.begin(), v.end());
    return v;
}

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> a_c, b_d;

    for(ll i=1; i*i<=K; i++){
        if(K%i!=0)
            continue;

        if(i!=K/i){
            a_c.push_back(i);
            b_d.push_back(K/i);
            a_c.push_back(K/i);
            b_d.push_back(i);
        }else{
            a_c.push_back(i);
            b_d.push_back(K/i);
        }
    }

    ll ans=0LL;
    for(ll i=0; i<a_c.size(); i++){
        ll mul1=a_c[i]-1, mul2=b_d[i]-1;
        if(mul1-N>0){
            if(2*N-mul1>=0){
                mul1=2*N-mul1;
            }else{
                mul1=0;
            }
        }
        if(mul2-N>0){
            if(2*N-mul2>=0){
                mul2=2*N-mul2;
            }else{
                mul2=0;
            }
        }
        ans+=mul1*mul2;
    }
    cout << ans << endl;
    return 0;
}
0