zawatins-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub zawa-tin/zawatins-library

:heavy_check_mark: test/ABC254-D.test.cpp

Depends on

Code

#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_A"

#include "../src/math/linearSieve.hpp"

#include <iostream>

int main() {
	// int N; std::cin >> N;
	// zawa::linearSieve siv(N);
	// std::vector<int> dp(N + 1, 1);
	// for (int i = 2 ; i < N + 1 ; i++) {
	// 	int lpf = siv[i];
	// 	dp[i] = dp[i / lpf];
	// 	if (dp[i] % lpf == 0) {
	// 		dp[i] /= lpf;
	// 	}
	// 	else {
	// 		dp[i] *= lpf;
	// 	}
	// }
	// std::vector bucket(N + 1, 0);
	// for (int i = 1 ; i < N + 1 ; i++) {
	// 	bucket[dp[i]]++;
	// }
	// long long ans = 0LL;
	// for (int i = 0 ; i < N + 1 ; i++) {
	// 	ans += (long long)bucket[i] * bucket[i];
	// }
	// std::cout << ans << std::endl;
	
	std::cout << "Hello World" << std::endl;
}

/*
 * AtCoder Beginner Contest 254 - D Together Square
 * https://atcoder.jp/contests/abc254/submissions/39448339
 */
#line 1 "test/ABC254-D.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_A"

#line 2 "src/math/linearSieve.hpp"

#include <vector>
#include <utility>

namespace zawa {

class linearSieve {
private:
	std::vector<int> divs;
	std::vector<int> primes;

public:
	linearSieve() {}
	linearSieve(std::size_t n) : divs(n + 1, 1) {
		for (std::size_t i = 2 ; i < n + 1 ; i++) {
			if (divs[i] == 1) {
				divs[i] = i;
				primes.push_back((int)i);
			}
			for (const auto& p : primes) {
				if (p * i > n or p > divs[i]) {
					break;
				}
				divs[p * i] = p;
			}
		}
	}

	std::vector<std::pair<int, int>> factorize(int x) {
		std::vector res(0, std::pair(0, 0));
		while (x > 1) {
			res.emplace_back(divs[x], 0);
			while (divs[x] == res.back().first) {
				x /= divs[x];
				res.back().second++;
			}
		}
		return res;
	}

	std::vector<int> divisor(int x) {
		std::vector res(1, 1);
		for (const auto& [p, q] : factorize(x)) {
			std::size_t now = res.size();
			for (std::size_t i = 0 ; i < now ; i++) {
				int mul = p;
				for (int _ = 0 ; _ < q ; _++) {
					res.emplace_back(res[i] * mul);
					mul *= p;
				}
			}
		}
		return res;
	}

	std::vector<int> enumPrime() {
		return primes;
	}

	int numPrime() {
		return (int)primes.size();
	}

	bool isPrime(int x) {
		return (x != 0 and x != 1 and divs[x] == x);
	}

	int operator[](int x) {
		return divs[x];
	}
};

}
#line 4 "test/ABC254-D.test.cpp"

#include <iostream>

int main() {
	// int N; std::cin >> N;
	// zawa::linearSieve siv(N);
	// std::vector<int> dp(N + 1, 1);
	// for (int i = 2 ; i < N + 1 ; i++) {
	// 	int lpf = siv[i];
	// 	dp[i] = dp[i / lpf];
	// 	if (dp[i] % lpf == 0) {
	// 		dp[i] /= lpf;
	// 	}
	// 	else {
	// 		dp[i] *= lpf;
	// 	}
	// }
	// std::vector bucket(N + 1, 0);
	// for (int i = 1 ; i < N + 1 ; i++) {
	// 	bucket[dp[i]]++;
	// }
	// long long ans = 0LL;
	// for (int i = 0 ; i < N + 1 ; i++) {
	// 	ans += (long long)bucket[i] * bucket[i];
	// }
	// std::cout << ans << std::endl;
	
	std::cout << "Hello World" << std::endl;
}

/*
 * AtCoder Beginner Contest 254 - D Together Square
 * https://atcoder.jp/contests/abc254/submissions/39448339
 */
Back to top page