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 603cec9

Browse files
committed
Problem 1
1 parent 5a2ac34 commit 603cec9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import scala.io.Source
2+
3+
object Solution {
4+
val in = {
5+
val lines = Source.stdin.getLines
6+
lines flatMap (_ split ' ' filter (_.nonEmpty))
7+
}
8+
def nextInt = in.next.toInt
9+
10+
def sum(n: Int): Long = 1L * n * (n + 1) / 2
11+
12+
def main(args: Array[String]): Unit = {
13+
val testCount = nextInt
14+
for (test <- 1 to testCount) {
15+
val N = nextInt - 1
16+
val ans = sum(N/3)*3 + sum(N/5)*5 - sum(N/15)*15
17+
println(ans)
18+
}
19+
}
20+
}

0 commit comments

Comments
(0)

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