結果
問題 | No.864 四方演算 |
ユーザー | Cyclone28 |
提出日時 | 2021-05-30 11:44:18 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 30 ms / 1,000 ms |
コード長 | 4,937 bytes |
コンパイル時間 | 2,938 ms |
コンパイル使用メモリ | 198,344 KB |
実行使用メモリ | 15,488 KB |
最終ジャッジ日時 | 2024-11-08 20:41:00 |
合計ジャッジ時間 | 4,620 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
15,488 KB |
testcase_01 | AC | 30 ms
15,360 KB |
testcase_02 | AC | 26 ms
15,360 KB |
testcase_03 | AC | 27 ms
15,488 KB |
testcase_04 | AC | 28 ms
15,360 KB |
testcase_05 | AC | 26 ms
15,488 KB |
testcase_06 | AC | 29 ms
15,488 KB |
testcase_07 | AC | 27 ms
15,360 KB |
testcase_08 | AC | 26 ms
15,360 KB |
testcase_09 | AC | 23 ms
15,488 KB |
testcase_10 | AC | 22 ms
15,488 KB |
testcase_11 | AC | 20 ms
15,488 KB |
testcase_12 | AC | 27 ms
15,360 KB |
testcase_13 | AC | 24 ms
15,488 KB |
testcase_14 | AC | 21 ms
15,488 KB |
testcase_15 | AC | 30 ms
15,488 KB |
testcase_16 | AC | 26 ms
15,488 KB |
testcase_17 | AC | 28 ms
15,488 KB |
testcase_18 | AC | 27 ms
15,488 KB |
testcase_19 | AC | 26 ms
15,488 KB |
testcase_20 | AC | 28 ms
15,488 KB |
testcase_21 | AC | 26 ms
15,360 KB |
testcase_22 | AC | 26 ms
15,488 KB |
testcase_23 | AC | 19 ms
15,488 KB |
testcase_24 | AC | 25 ms
15,360 KB |
testcase_25 | AC | 21 ms
15,360 KB |
testcase_26 | AC | 25 ms
15,488 KB |
testcase_27 | AC | 17 ms
15,360 KB |
testcase_28 | AC | 18 ms
15,488 KB |
testcase_29 | AC | 18 ms
15,360 KB |
ソースコード
//C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif #if __cplusplus >= 201402L #include <shared_mutex> #endif #if __cplusplus >= 201703L #include <any> #include <charconv> // #include <execution> #include <filesystem> #include <optional> #include <memory_resource> #include <string_view> #include <variant> #endif #if __cplusplus > 201703L #include <barrier> #include <bit> #include <compare> #include <concepts> #if __cpp_impl_coroutine #include <coroutine> #endif #include <latch> #include <numbers> #include <ranges> #include <span> #include <stop_token> #include <semaphore> #include <source_location> #include <syncstream> #include <version> #endif //C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif #include<atcoder/convolution> using namespace atcoder; //#define int ll using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using Graph = vector<vector<ll>>; #define rep1(i, n) for(ll i = 0; i < (int)(n); i++) #define rep2(i, a, b) for(ll i = (int)(a); i < (int)(b); i++) #define rep3(i, a, b, c) for(ll i = (int)(a); i < (int)(b); i+=(int)(c)) #define rrep1(i, n) for(ll i = (int)(n); i >= 0; i--) #define rrep2(i, a, b) for(ll i = (int)(b); i >= (int)(a); i--) #define REP(i) for(ll i = 0; ; i++) #define all(v) (v).begin(), (v).end() template<class T> using pq = priority_queue<T, vector<T>, greater<T>>; template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; } template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; } template<class T> auto min(const T& a){ return *min_element(all(a)); } template<class T> auto max(const T& a){ return *max_element(all(a)); } template<class T> ll sum(const T& a){ return accumulate(all(a), 0LL); } template<class T> ld dsum(const T& a){ return accumulate(all(a), 0.0L); } const int MOD = 1000000007; const int MMOD = 998244353; const int MAX = 510000; const ll INF = 1LL<<60; ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; } ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); } ll POW(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; } ll MODPOW(ll a, ll b){ ll ret = 1; while(b){ if(b & 1) ret = ret*a%MOD; a = a*a%MOD; b /= 2;} return ret;} long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } bool is_prime(ll n){ if(n == 1) return false; if(n == 2) return true; for(ll i = 2; i*i<=n; i++) if(n%i == 0) return false; return true; } signed main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); COMinit(); ll N, K; cin >> N >> K; ll ans = 0; rep2(i, 1, sqrt(K)+1){ if(K%i==0){ ll c1 = 0, c2 = 0; c1 += (i <= 1 || i > 2*N ? 0 : (2 <= i && i <= N+1 ? i-1 : 2*N-i+1)); ll Q = K/i; c2 += (Q <= 1 || Q > 2*N ? 0 : (2 <= Q && Q <= N+1 ? Q-1 : 2*N-Q+1)); ans += c1*c2*2; if(i*i == K) ans -= c1*c2; } } cout << ans << endl; }