結果

問題 No.1514 Squared Matching
ユーザー kwm_tkwm_t
提出日時 2021-05-22 17:23:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,707 ms / 4,000 ms
コード長 1,704 bytes
コンパイル時間 1,703 ms
コンパイル使用メモリ 163,364 KB
実行使用メモリ 394,368 KB
最終ジャッジ日時 2024-04-18 22:09:45
合計ジャッジ時間 27,858 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1,707 ms
394,112 KB
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 3 ms
5,376 KB
testcase_06 AC 16 ms
9,472 KB
testcase_07 AC 237 ms
78,080 KB
testcase_08 AC 1,394 ms
380,032 KB
testcase_09 AC 1,195 ms
332,800 KB
testcase_10 AC 1,304 ms
360,192 KB
testcase_11 AC 1,372 ms
374,784 KB
testcase_12 AC 1,408 ms
385,280 KB
testcase_13 AC 1,425 ms
390,400 KB
testcase_14 AC 1,426 ms
392,448 KB
testcase_15 AC 1,462 ms
393,472 KB
testcase_16 AC 1,444 ms
394,112 KB
testcase_17 AC 1,480 ms
394,112 KB
testcase_18 AC 1,453 ms
394,204 KB
testcase_19 AC 1,442 ms
393,984 KB
testcase_20 AC 1,454 ms
394,368 KB
testcase_21 AC 1,460 ms
394,112 KB
testcase_22 AC 252 ms
81,664 KB
testcase_23 AC 552 ms
160,000 KB
testcase_24 AC 852 ms
237,952 KB
testcase_25 AC 1,144 ms
316,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
long long table[50000007];
bool is_prime[50000007];

//エラトステネスの篩(素数の数を返している)
//11→2,3,5,7,11
int sieve(long long  n) {
	int p = 0;
	is_prime[0] = false;
	is_prime[1] = false;
	for (int m = 2; m <= sqrt(n); ++m) {//初期化
		is_prime[m] = true;
	}

	for (int m = 2; m <= sqrt(n); ++m) {
		if (is_prime[m]) {
			++p;
			//素数なら。
			long long now = m * m;
			while (now <= n) {
				for (long long i = now; i <= n; i += now) {
					table[i] /= (m*m);
				}
				now *= m * m;
			}

			for (int l = 2 * m; l <= sqrt(n); l += m) is_prime[l] = false;
		}
	}
	return p;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	rep(i, n + 1)table[i] = i;
	sieve(n);
	long long ans = 0;
	rep2(i, 1, n + 1) {
		ans += sqrt(n / table[i]);
	}
	cout << ans << endl;
	return 0;
}
0