結果
問題 | No.864 四方演算 |
ユーザー | yu-ta38 |
提出日時 | 2022-06-05 17:25:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,000 ms |
コード長 | 7,367 bytes |
コンパイル時間 | 1,333 ms |
コンパイル使用メモリ | 119,708 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 04:13:08 |
合計ジャッジ時間 | 2,661 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 13 ms
5,376 KB |
testcase_02 | AC | 9 ms
5,376 KB |
testcase_03 | AC | 10 ms
5,376 KB |
testcase_04 | AC | 11 ms
5,376 KB |
testcase_05 | AC | 8 ms
5,376 KB |
testcase_06 | AC | 11 ms
5,376 KB |
testcase_07 | AC | 10 ms
5,376 KB |
testcase_08 | AC | 10 ms
5,376 KB |
testcase_09 | AC | 6 ms
5,376 KB |
testcase_10 | AC | 6 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 10 ms
5,376 KB |
testcase_13 | AC | 7 ms
5,376 KB |
testcase_14 | AC | 4 ms
5,376 KB |
testcase_15 | AC | 13 ms
5,376 KB |
testcase_16 | AC | 10 ms
5,376 KB |
testcase_17 | AC | 11 ms
5,376 KB |
testcase_18 | AC | 10 ms
5,376 KB |
testcase_19 | AC | 8 ms
5,376 KB |
testcase_20 | AC | 11 ms
5,376 KB |
testcase_21 | AC | 10 ms
5,376 KB |
testcase_22 | AC | 9 ms
5,376 KB |
testcase_23 | AC | 3 ms
5,376 KB |
testcase_24 | AC | 9 ms
5,376 KB |
testcase_25 | AC | 5 ms
5,376 KB |
testcase_26 | AC | 9 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
ソースコード
#include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <set> #include <map> #include <deque> #include <queue> #include <stack> #include <iomanip> // #include <atcoder/all> // using namespace atcoder; using namespace std; typedef long long int ll; typedef pair<int, int> Pint; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<char> vc; typedef vector<string> vs; typedef vector<bool> vb; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i <= (int)(n); i++) const ll INF = 1LL << 60; struct dsu { vector<int> d; dsu(int n = 0): d(n,-1) {} int findRoot(int x) { if(d[x] < 0) return x; return d[x] = findRoot(d[x]); } bool unite(int x,int y) { x = findRoot(x); y = findRoot(y); if(x == y) return false; if(d[x] > d[y]) swap(x,y); d[x] += d[y]; d[y] = x; return true; } bool same(int x,int y) { return findRoot(x) == findRoot(y);} int size(int x) {return -d[findRoot(x)];} }; template <typename T> struct RMQ { const T INF = numeric_limits<T>::max(); int n; vector<T> dat; RMQ(int n_) : n(), dat(n_ * 4, INF) { int x = 1; while(n_ > x) { x *= 2; } n = x; } void update(int i, T x) { i += n - 1; dat[i] = x; while(i > 0) { i = (i - 1) / 2; dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]); } } T query(int a, int b) { return query_sub(a,b,0,0,n); } T query_sub(int a, int b, int k, int l, int r) { if(r <= a || b <= l) { return INF; }else if(a <= l && r <= b) { return dat[k]; }else { T vl = query_sub(a,b,k * 2 + 1, l, (l + r) / 2); T vr = query_sub(a,b,k * 2 + 2, (l + r) / 2, r); return min(vl, vr); } } }; struct Edge { int to; ll w; Edge(int to, ll w) : to(to), w(w) {} }; using WeightedGraph = vector<vector<Edge>>; // 関数の性質上重み付きグラフをグローバル変数に宣言している vector<ll> dijkstra(WeightedGraph Graph,int N, int s); double getDistance(double x1, double y1, double x2, double y2); double getAngle(double xa, double ya, double xb, double yb, double xc, double yc); bool primeCheck(ll N); template<class T> bool chmax(T& a, T b); template<class T> bool chmin(T& a, T b); template<class T> T base_n_to_ll(string S, T n); template<class T> string ll_to_base_n(T num, T n); template<class T> vector<T> divisorEnumeration(T K); template<class T> vector<T> primeFactorization(T N); template<class T> vector<T> cumulativeSum(vector<T> a); ll hspow(ll a, ll n); ll modpow(ll a, ll n, ll mod); ll modinv(ll a, ll b, ll mod); ll simpleCombination(ll n, ll r); ll modCombination(ll n, ll r, ll mod); ll gcd(ll a, ll b); ll lcm(ll a, ll b); #define MOD (int)998244353 // 以下solve() // Global変数なら3e8までメモリ確保可能 const int MAX_N = 200005; void solve() { ll N,K; cin>>N>>K; vector<ll> divisor = divisorEnumeration(K); ll ans = 0; for(auto t : divisor) { ll x,y; ll mid = (2 * N + 2) / 2; if(t<=1||2*N<t) x = 0; else if(2<=t&&t<=mid) x = t - 1; else x = mid * 2 - t - 1; ll t_ = K/t; if(t_<=1||2*N<t_) y = 0; else if(2<=t_&&t_<=mid) y = t_ - 1; else y = mid * 2 - t_ - 1; // cout<<x<<' '<<y<<endl; ans += (x * y); } cout<<ans<<endl; } int main() { solve(); return 0; } // ***************** // ***************** // * function * // ***************** // ***************** bool primeCheck(ll N) { for (ll i = 2; i * i <= N; i++) { if (N % i == 0) return false; } return true; } double getDistance(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } double getAngle(double xa, double ya, double xb, double yb, double xc, double yc) { double VectorAB = sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya)); double VectorAC = sqrt((xc - xa) * (xc - xa) + (yc - ya) * (yc - ya)); double Naiseki = (xb - xa) * (xc - xa) + (yb - ya) * (yc - ya); double cosTheta = Naiseki / (VectorAB * VectorAC); return acos(cosTheta) * 180.0 / M_PI; } template<class T> vector<T> cumulativeSum(vector<T> a) { T sum = 0, n = a.size(); vector<T> s(n+1); s[0] = 0; for(int i = 1;i <= n;++i) { s[i] = a[i] + s[i-1]; } return s; } long long simpleCombination(long long n, long long r) { long long sum = 1; if(r > n - r) r = n - r; for(int i = 1;i <= r;++i) { sum *= (n - i + 1); sum /= i; } return sum; } long long modCombination(long long n, long long r, long long mod) { long long sum = 0, a = 1, b = 1, condition; if(n/2 < r) r = n - r; condition = n - r; for(int i = 1;i <= n;++i) { if(i <= r) { b = (b * i) % mod; } if(i > condition) { a = (a * i) % mod; } } sum = modinv(a, b, mod); return sum; } ll hspow(ll a, ll n) { ll res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long b, long long mod) { return a * modpow(b, mod - 2, mod) % mod; } ll gcd(ll a, ll b) {if(b == 0) return a;else {return gcd(b, a%b);}} ll lcm(ll a, ll b) {return a * gcd(a,b) / b;} template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;} template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;} template<class T> T base_n_to_ll(string S, T n) { T res = 0; rep(i,S.size()) { res = res*n + (S[i]-'0'); } return res; } template<class T> string ll_to_base_n(T num, T n) { if(num == 0) return "0"; string res = ""; while(num>0) { res = char((num%n) + '0') + res; num /= n; } return res; } template<class T> vector<T> divisorEnumeration(T K) { vector<T> divisor; for(T i = 1; i * i <= K; i++) { if(K % i != (T)0) continue; divisor.push_back(i); if(i != (K / i)) divisor.push_back(K / i); } sort(divisor.begin(),divisor.end()); return divisor; } template<class T> vector<T> primeFactorization(T N) { vector<T> prime; for(T i = 2; i * i <= N; i++) { while(N % i == 0) { N /= i; prime.push_back(i); } } if(N != (T)1) prime.push_back(N); return prime; } vector<ll> dijkstra(WeightedGraph Graph,int N, int s) { vector<ll> dist(N,INF); dist[s] = 0; priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que; que.push(make_pair(dist[s],s)); while(!que.empty()) { int v = que.top().second; ll d = que.top().first; que.pop(); if(d > dist[v]) continue; for(auto e : Graph[v]) { if(chmin(dist[e.to], dist[v] + e.w)) { que.push(make_pair(dist[e.to],e.to)); } } } return dist; }