結果
| 問題 | No.864 四方演算 |
| コンテスト | |
| ユーザー |
hiroa
|
| 提出日時 | 2021-08-05 21:23:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 1,000 ms |
| コード長 | 951 bytes |
| 記録 | |
| コンパイル時間 | 1,628 ms |
| コンパイル使用メモリ | 172,560 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 15:24:32 |
| 合計ジャッジ時間 | 2,889 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
// 約数の列挙O(√n)
vector<ll> enum_divisors(ll n){
vector<ll> res;
for(ll i=1;i*i<=n;i++){
if(n%i==0){
res.push_back(i);
// 重複しないならばiの相方であるN/iもpush
if(i!=n/i) res.push_back(n/i);
}
}
// 小さい順に並び替える
sort(res.begin(), res.end());
return res;
}
int main(){
ll N,K;
cin>>N>>K;
auto ed=enum_divisors(K);
ll ans=0;
for(auto x : ed){
ll tmp=1;
ll y=K/x;
if(N>=x-1) tmp*=(x-1);
else tmp*=(x-1-(x-1-N)*2);
if(N>=y-1) tmp*=(y-1);
else tmp*=(y-1-(y-1-N)*2);
ans+=max(tmp,0LL);
//cout<<x<<" "<<y<<" "<<abs(tmp)<<endl;
}
cout<<ans<<endl;
}
hiroa