結果
問題 | No.864 四方演算 |
ユーザー |
![]() |
提出日時 | 2019-08-16 21:36:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 1,000 ms |
コード長 | 1,111 bytes |
コンパイル時間 | 1,287 ms |
コンパイル使用メモリ | 101,964 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 10:43:27 |
合計ジャッジ時間 | 2,273 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <assert.h> #include <limits.h> #include <cmath> #include <algorithm> #include <bitset> #include <cctype> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using ll = long long; using P = std::pair<ll, ll>; #define rep(i, a, b) for (ll(i) = (a); i < (b); i++) #define all(i) i.begin(), i.end() #define debug(i) std::cout << i << "\n" //const ll MOD = 998244353; const ll MOD = 1e9+7; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); //問題文中の添え字が0-indexか1-indexか確認! ll n,k; std::cin>>n>>k; std::vector<ll> fact; for(ll i=1;i*i<=k;i++){ if(k%i==0){ fact.push_back(i); if(i*i!=k)fact.push_back(k/i); } } ll ans=0; std::sort(all(fact)); for(ll i:fact){ ll temp1=0,temp2=0; if(i<=n+1)temp1=i-1; else if(i<=2*n)temp1=2*n-i+1; if(k/i<=n+1)temp2=k/i-1; else if(k/i<=2*n)temp2=2*n-k/i+1; ans+=temp1*temp2; } std::cout<<ans<<"\n"; return 0; }