Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created June 6, 2018 01:48
Show Gist options
  • Save whatalnk/62233a0c13c04360670fdae1f93bc108 to your computer and use it in GitHub Desktop.
Save whatalnk/62233a0c13c04360670fdae1f93bc108 to your computer and use it in GitHub Desktop.
AtCoder ABC #097 B
x = gets.chomp.to_i
y = Math.sqrt(x).to_i + 1
if x == 1 then
puts 1
exit
end
ans = 1
2.upto(y) do |i|
a = i
10.times do |j|
a *= i
if a > x then
break
elsif a > ans then
ans = a
end
end
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment