Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f06ba15

Browse files
committed
Problem 5
1 parent 4f33efe commit f06ba15

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import scala.math.log
2+
3+
object Solution {
4+
5+
val in = {
6+
val lines = scala.io.Source.stdin.getLines
7+
lines flatMap (_ split ' ' filter (_.nonEmpty))
8+
}
9+
10+
def nextInt = in.next.toInt
11+
12+
val primes = Seq(2, 3, 5, 7, 11, 13, 17 ,19, 23, 29, 31, 37)
13+
14+
def main(args: Array[String]): Unit = {
15+
val testCount = nextInt
16+
for (test <- 1 to testCount) {
17+
val N = nextInt
18+
val primesExp = primes zip (primes map (p => (log(N) / log(p)).toInt))
19+
val powers = primesExp map { case (p, e) => math.pow(p, e).toLong }
20+
println(powers.product)
21+
}
22+
}
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /