結果
問題 | No.1514 Squared Matching |
ユーザー |
👑 ![]() |
提出日時 | 2021-05-21 22:53:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 870 bytes |
コンパイル時間 | 2,030 ms |
コンパイル使用メモリ | 196,156 KB |
実行使用メモリ | 589,540 KB |
最終ジャッジ日時 | 2024-04-18 16:20:48 |
合計ジャッジ時間 | 21,079 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | MLE | - |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 16 ms
12,504 KB |
testcase_07 | AC | 181 ms
115,384 KB |
testcase_08 | MLE | - |
testcase_09 | AC | 911 ms
497,168 KB |
testcase_10 | MLE | - |
testcase_11 | MLE | - |
testcase_12 | MLE | - |
testcase_13 | MLE | - |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | MLE | - |
testcase_19 | MLE | - |
testcase_20 | MLE | - |
testcase_21 | MLE | - |
testcase_22 | AC | 209 ms
120,736 KB |
testcase_23 | AC | 420 ms
237,956 KB |
testcase_24 | AC | 645 ms
354,980 KB |
testcase_25 | AC | 859 ms
472,296 KB |
ソースコード
#include <bits/stdc++.h> #include <iostream> #include <limits> #include <numeric> #include <type_traits> using namespace std; #define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++) #define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--) using ll = long long; const ll mod = 998244353; int main(){ ll N; cin >> N; ll maxd[N+1]; rep(i,0,N+1) maxd[i] = 1; rep(i,1,N+1){ for (ll j = i*i ; j < N+1 ; j += i*i){ maxd[j] = max(maxd[j],i*i); } } int xlis[N+1]; rep(i,0,N+1) xlis[i] = 0; rep(i,1,N+1){ ll x = i / maxd[i]; xlis[x]++; } //aの値が、 平方数 * そうでない数x は求まった //そうでない数xで分類すればよい //あとは適当にペア計算 ll ans = 0; rep(i,0,N+1){ ans += xlis[i]*((ll)xlis[i]); } cout << ans << endl; }