結果
問題 | No.500 階乗電卓 |
ユーザー |
|
提出日時 | 2021-01-10 20:20:23 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 350 ms / 2,000 ms |
コード長 | 878 bytes |
コンパイル時間 | 13,904 ms |
コンパイル使用メモリ | 431,080 KB |
実行使用メモリ | 55,304 KB |
最終ジャッジ日時 | 2024-11-21 08:34:03 |
合計ジャッジ時間 | 22,120 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
import java.io.PrintWriterimport java.util.*import kotlin.math.*fun PrintWriter.solve() {val n = nextLong()var fac = 1Lval lim = 1000000000000var over = falsefor (i in 1..n) {fac *= iif (fac >= lim) over = truefac %= limif (fac == 0L) break}if (!over) {println(fac)} else {println("%012d".format(fac))}}fun main() {val writer = PrintWriter(System.out, false)writer.solve()writer.flush()}// region Scannerprivate var st = StringTokenizer("")private val br = System.`in`.bufferedReader()fun next(): String {while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())return st.nextToken()}fun nextInt() = next().toInt()fun nextLong() = next().toLong()fun nextLine() = br.readLine()!!fun nextDouble() = next().toDouble()// endregion