結果
| 問題 | 
                            No.864 四方演算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             merom686
                         | 
                    
| 提出日時 | 2019-08-16 21:42:34 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 13 ms / 1,000 ms | 
| コード長 | 647 bytes | 
| コンパイル時間 | 663 ms | 
| コンパイル使用メモリ | 73,412 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-25 10:44:21 | 
| 合計ジャッジ時間 | 1,736 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
    ll n, k;
    cin >> n >> k;
    auto f = [n](ll i) {
        if (i <= n + 1) return i - 1;
        ll t = n * 2 - i;
        if (t < 0) return 0LL;
        return t + 1;
    };
    ll r = 0;
    for (ll i = 2; i * i <= k; i++) {
        if (k % i == 0) {
            ll j = k / i;
            ll t = f(i) * f(j);
            if (i != j) t *= 2;
            r += t;
        }
    }
    cout << r << endl;
    //(a+c)(b+d)=ab+bc+cd+da=k
    return 0;
}
            
            
            
        
            
merom686