結果
問題 | No.1514 Squared Matching |
ユーザー | ayoiyouyoeyo |
提出日時 | 2021-05-21 22:24:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,560 ms / 4,000 ms |
コード長 | 2,885 bytes |
コンパイル時間 | 3,591 ms |
コンパイル使用メモリ | 179,820 KB |
実行使用メモリ | 205,568 KB |
最終ジャッジ日時 | 2024-10-10 09:11:48 |
合計ジャッジ時間 | 31,064 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1,560 ms
205,440 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 26 ms
6,820 KB |
testcase_07 | AC | 295 ms
42,112 KB |
testcase_08 | AC | 1,481 ms
198,272 KB |
testcase_09 | AC | 1,300 ms
173,824 KB |
testcase_10 | AC | 1,411 ms
187,904 KB |
testcase_11 | AC | 1,461 ms
195,712 KB |
testcase_12 | AC | 1,522 ms
200,960 KB |
testcase_13 | AC | 1,537 ms
203,648 KB |
testcase_14 | AC | 1,547 ms
204,672 KB |
testcase_15 | AC | 1,551 ms
205,184 KB |
testcase_16 | AC | 1,553 ms
205,440 KB |
testcase_17 | AC | 1,547 ms
205,568 KB |
testcase_18 | AC | 1,555 ms
205,568 KB |
testcase_19 | AC | 1,552 ms
205,568 KB |
testcase_20 | AC | 1,552 ms
205,568 KB |
testcase_21 | AC | 1,551 ms
205,568 KB |
testcase_22 | AC | 309 ms
44,032 KB |
testcase_23 | AC | 615 ms
84,480 KB |
testcase_24 | AC | 921 ms
124,928 KB |
testcase_25 | AC | 1,240 ms
165,248 KB |
ソースコード
#include <iostream>#include <string>#include <cmath>#include<algorithm>#include<stack>#include<queue>#include<map>#include<set>#include<iomanip>#include<bitset>#define _USE_MATH_DEFINES#include <math.h>#include <functional>#include<complex>#include<cassert>#include<random>using namespace std;#include<atcoder/all>using namespace atcoder;#define rep(i,x) for(ll i=0;i<x;i++)#define repn(i,x) for(ll i=1;i<=x;i++)typedef long long ll;typedef pair<ll, ll> P;const ll INF = 1e17;const ll MAX = 4000001;const long double eps = 1E-14;ll max(ll a, ll b) {if (a > b) { return a; }return b;}ll min(ll a, ll b) {if (a > b) { return b; }return a;}ll gcd(ll a, ll b) {if (b == 0) { return a; }if (a < b) { return gcd(b, a); }return gcd(b, a % b);}ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}struct edge {ll id;ll fr;ll to;ll d;};using mint = modint;typedef vector<ll> vll;typedef vector <vector<ll>> vvll;typedef vector<vector<vector<ll>>> vvvll;typedef vector<mint> vmint;typedef vector<vector<mint>> vvmint;typedef vector<vector<vector<mint>>> vvvmint;vmint f, finv, inv;void cominit(ll N) {ll MOD = modint::mod();//デフォルトが998244353に注意f.assign(N + 1, 1);finv.assign(N + 1, 1);inv.assign(N + 1, 1);inv[1] = 1;repn(i, N) {f[i] = f[i - 1] * i;if (i > 1)inv[i] = -inv[MOD % i] * (MOD / i);finv[i] = finv[i - 1] * inv[i];}}mint com(ll a, ll b) {if (a < 0 || b < 0 || a < b) { return 0; }return f[a] * finv[b] * finv[a - b];}/////////////////////////////////////vvmint prod(vvmint a, vvmint b) {ll N = a.size();vvmint ret(N, vmint(N, 0));rep(i, N)rep(j, N)rep(k, N) {ret[i][j] += a[i][k] * b[k][j];}return ret;}vvmint pw(vvmint a, ll K) {ll N = a.size();if(K==0){vvmint ret(N, vmint(N, 0));rep(i, N)ret[i][i] = 1;return ret;}vvmint ret = pw(a, K / 2);ret = prod(ret, ret);if (K % 2 == 1)ret = prod(ret, a);return ret;}bool cad(ll a, ll b, ll c) {if (a == b || a == c || b == c) { return false; }if (max(a, max(b, c)) == b || min(a, min(b, c)) == b) { return true; }return false;}int main() {ll N;cin >> N;ll M = sqrt(N) + 3;vector<vector<bool>> cp(M, vector<bool>(M, 0));cp[0][1] = 1;cp[1][0] = 1;repn(x, M-1)repn(y, M-1) {if (x > y) { cp[x][y] = cp[y][x]; }cp[x][y] = cp[y%x][x];}vector<vector<int>> rdp(M, vector<int>(M, 0));repn(x, M-1)repn(y, M-1) {if (x > 0)rdp[x][y] += rdp[x - 1][y];if (y > 0)rdp[x][y] += rdp[x][y - 1];if (x > 0 && y > 0)rdp[x][y] -= rdp[x - 1][y - 1];rdp[x][y] += cp[x][y];//cout << x << " " << y << rdp[x][y] << endl;}ll ans = 0;repn(i, N) {ll now = N / i;//cout << now << endl;//cout << rdp[sqrt(now + 1e-8)][sqrt(now + 1e-8)] << endl;ans += rdp[sqrt(now + 1e-8)][sqrt(now + 1e-8)];}cout << ans << endl;}