結果

問題 No.1514 Squared Matching
ユーザー inksamuraiinksamurai
提出日時 2021-07-03 20:59:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,399 ms / 4,000 ms
コード長 1,759 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 102,372 KB
実行使用メモリ 394,252 KB
最終ジャッジ日時 2023-09-13 02:33:40
合計ジャッジ時間 39,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,293 ms
394,048 KB
testcase_01 AC 1,382 ms
394,036 KB
testcase_02 AC 1,294 ms
393,992 KB
testcase_03 AC 1,289 ms
394,104 KB
testcase_04 AC 1,283 ms
393,968 KB
testcase_05 AC 1,284 ms
393,988 KB
testcase_06 AC 1,298 ms
394,028 KB
testcase_07 AC 1,305 ms
393,996 KB
testcase_08 AC 1,379 ms
393,996 KB
testcase_09 AC 1,368 ms
394,032 KB
testcase_10 AC 1,389 ms
393,984 KB
testcase_11 AC 1,367 ms
394,032 KB
testcase_12 AC 1,370 ms
393,992 KB
testcase_13 AC 1,374 ms
394,164 KB
testcase_14 AC 1,384 ms
394,036 KB
testcase_15 AC 1,377 ms
393,976 KB
testcase_16 AC 1,376 ms
394,252 KB
testcase_17 AC 1,373 ms
394,040 KB
testcase_18 AC 1,380 ms
393,972 KB
testcase_19 AC 1,368 ms
393,996 KB
testcase_20 AC 1,383 ms
393,980 KB
testcase_21 AC 1,399 ms
393,968 KB
testcase_22 AC 1,321 ms
393,996 KB
testcase_23 AC 1,339 ms
394,036 KB
testcase_24 AC 1,347 ms
394,104 KB
testcase_25 AC 1,373 ms
393,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip> 
#include <stdio.h>
#include <assert.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define pii pair <int,int>
#define ftpii pair<pii,pii>
#define rep(i,n) for(int i = 0 ; i < n ; i++) 
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define vi vector <int> 
#define vec(...) vector<__VA_ARGS__>
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//eodefine
using namespace std;

const int _maxn = 5e7+3;

int d[_maxn+100],prm[_maxn+10];

void fdprm(int nupto) {
	crep(i,2,sqrt(nupto)+1){
		if(prm[i] == 0) {
			for(int j = i*i ; j <= nupto ; j += i) prm[j] = i;
		}
	}
}

int main(){
fcin;
// 	fdprm(_maxn);

	rep(i,_maxn) d[i]=i;

	crep(p,2,sqrt(_maxn)){
	    if(prm[p]) continue;
	    if(p*p>_maxn) break;
		for(int j=p*p;j<=_maxn;j+=p*p){
			while(d[j]>1 and d[j]%(p*p)==0) d[j]/=(p*p);
		}
		for(int j = p*p ; j <= _maxn ; j += p) prm[j] = p;
	}
	
	rep(i,_maxn) prm[i]=0;
    
    int n;
    cin>>n;
    
    rep(i,n+1){
        prm[d[i]]++;
    }
    
    ll ans=0;
    crep(i,1,n+1){
        ans+=(ll)prm[i]*prm[i];
    }
    
    cout<<ans<<"\n";
/*
*/
	return 0;
}
0