結果

問題 No.864 四方演算
ユーザー tomahoku001
提出日時 2019-10-11 01:43:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 657 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 167,020 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-22 08:35:54
合計ジャッジ時間 2,806 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(){
    LL N, K;
    cin >> N >> K;
    LL ans = 0;
    for(LL i = 1;i*i <= K;i++){
        if(K%i == 0){
            LL a = i;
            LL b = K/i;
            LL res = 1;
            if(a <= 2*N){
                if(a-1 <= N)    res *= a-1;
                else    res *= 2*N-a+1;
            } else  res = 0;
            if(b <= 2*N){
                if(b-1 <= N)    res *= b-1;
                else    res *= 2*N-b+1;
            } else   res = 0;
            ans += res;
            if(a != b)  ans += res;
        }
    }
    cout << ans << endl;
}
0