結果
問題 | No.1514 Squared Matching |
ユーザー | beet |
提出日時 | 2021-05-21 21:28:39 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 865 bytes |
コンパイル時間 | 2,094 ms |
コンパイル使用メモリ | 193,392 KB |
実行使用メモリ | 589,568 KB |
最終ジャッジ日時 | 2024-04-18 14:32:14 |
合計ジャッジ時間 | 33,317 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | MLE | - |
testcase_02 | AC | 3 ms
5,376 KB |
testcase_03 | AC | 3 ms
5,376 KB |
testcase_04 | AC | 3 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 21 ms
12,672 KB |
testcase_07 | AC | 312 ms
115,712 KB |
testcase_08 | MLE | - |
testcase_09 | AC | 1,571 ms
497,152 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 | 321 ms
120,704 KB |
testcase_23 | AC | 665 ms
238,080 KB |
testcase_24 | AC | 1,004 ms
355,072 KB |
testcase_25 | AC | 1,356 ms
472,320 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using Int = long long; const char newl = '\n'; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} template<typename T=Int> vector<T> read(size_t n){ vector<T> ts(n); for(size_t i=0;i<n;i++) cin>>ts[i]; return ts; } //INSERT ABOVE HERE const Int MAX = 5e7 + 100; signed dp[MAX]; Int cnt[MAX]; signed main(){ cin.tie(0); ios::sync_with_stdio(0); Int n; cin>>n; for(Int i=1;i<=n;i++) dp[i]=i; for(Int i=2;i*i<=n;i++){ Int s=i*i; for(Int j=s;j<=n;j+=s) while(dp[j]%s==0) dp[j]/=s; } Int ans=0; for(Int i=1;i<=n;i++) cnt[dp[i]]++; for(Int i=1;i<=n;i++) ans+=cnt[i]*cnt[i]; cout<<ans<<newl; return 0; }