2026年9月9日上午正上着班,猫耳FM就弹出了《全职高手》广播剧第四季的正式预告,想着这未来的21周的时间每周都有听觉盛宴,心里高兴极了。
今晚下班后,怀着激动的心情,屁颠屁颠地explore the Atcoder,又遇到了一道基础数学题。
Atcoder Beginner Contest 193 C.Unexpressed
Time Limit: 2 sec / Memory Limit: 1024 MiB
Score : 300 points
Problem Statement
Given is an integer N. How many integers between 1 and N (inclusive) are unrepresentable as a^b, where a and b are integers not less than 2?
Constraints
N is an integer.
1 ≤ N ≤ 10^10
Input
Input is given from Standard Input in the following format:
N
Output
Print the answer.
solution
n = gets.to_i
m = n.pow(0.5).ceil
h = {}
m.downto(2) do |i|
x = Math.log(n, i).floor
if x >= 2
(2..x).each do |j|
h[i ** j] = 1
end
end
end
puts n - h.length
AC啦,欢迎方锐大大加入兴欣战队!