結果
| 問題 | 
                            No.864 四方演算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             QCFium
                         | 
                    
| 提出日時 | 2019-08-16 21:30:21 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 23 ms / 1,000 ms | 
| コード長 | 594 bytes | 
| コンパイル時間 | 1,608 ms | 
| コンパイル使用メモリ | 167,032 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-25 10:42:17 | 
| 合計ジャッジ時間 | 2,862 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
#include <bits/stdc++.h>
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}
int64_t calc(int64_t sum, int64_t max) {
	return std::max<int64_t>(0, std::min(sum - 1, max) - std::max((int64_t) 1, sum - max) + 1);
}
int main() {
	int64_t n = rll(), k = rll();
	int64_t res = 0;
	for (int i = 2; i <= k / i; i++) {
		if (k % i == 0) {
			int64_t x = i;
			int64_t y = k / i;
			res += calc(x, n) * calc(y, n);
			if ((int64_t) i * i != k) {
				res += calc(x, n) * calc(y, n);
			}
		}
	}
	std::cout << res << std::endl;
	return 0;
}
            
            
            
        
            
QCFium