結果

問題 No.1514 Squared Matching
ユーザー 👑 kmjpkmjp
提出日時 2021-05-21 22:34:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 801 ms / 4,000 ms
コード長 1,130 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 195,660 KB
実行使用メモリ 394,240 KB
最終ジャッジ日時 2024-04-18 16:05:24
合計ジャッジ時間 15,932 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 801 ms
394,048 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 12 ms
9,472 KB
testcase_07 AC 140 ms
78,080 KB
testcase_08 AC 754 ms
379,904 KB
testcase_09 AC 712 ms
332,544 KB
testcase_10 AC 704 ms
360,320 KB
testcase_11 AC 722 ms
374,912 KB
testcase_12 AC 748 ms
385,280 KB
testcase_13 AC 764 ms
390,400 KB
testcase_14 AC 761 ms
392,448 KB
testcase_15 AC 764 ms
393,344 KB
testcase_16 AC 762 ms
393,856 KB
testcase_17 AC 761 ms
394,240 KB
testcase_18 AC 766 ms
393,984 KB
testcase_19 AC 756 ms
394,168 KB
testcase_20 AC 759 ms
393,984 KB
testcase_21 AC 760 ms
394,240 KB
testcase_22 AC 149 ms
81,664 KB
testcase_23 AC 301 ms
159,744 KB
testcase_24 AC 456 ms
237,696 KB
testcase_25 AC 616 ms
315,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
int num[50000001];
int dp[50000001];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(i=1;i<=N;i++) num[i]=i;
	for(i=2;i*i<=N;i++) {
		for(j=i*i;j<=N;j+=i*i) while(num[j]%(i*i)==0) num[j]/=i*i;
	}
	for(i=1;i<=N;i++) dp[num[i]]++;
	
	
	ll ret=0;
	FOR(i,N+1) if(dp[i]) ret+=1LL*dp[i]*dp[i];
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0