結果
問題 | No.276 連続する整数の和(1) |
ユーザー |
![]() |
提出日時 | 2020-12-16 23:33:52 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 289 ms / 1,000 ms |
コード長 | 362 bytes |
コンパイル時間 | 11,213 ms |
コンパイル使用メモリ | 424,980 KB |
実行使用メモリ | 50,996 KB |
最終ジャッジ日時 | 2024-09-20 05:27:29 |
合計ジャッジ時間 | 15,341 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
Main.kt:6:13: warning: 'appendln(Long): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator. builder.appendln(gcd(n, n * (n + 1L) / 2L)) ^
ソースコード
fun main() {val builder = StringBuilder()val n = readInputLine().toLong()builder.appendln(gcd(n, n * (n + 1L) / 2L))print(builder.toString())}fun readInputLine(): String {return readLine()!!}tailrec fun gcd(a: Long, b: Long): Long =when {b > a -> gcd(b, a)b == 0L -> aelse -> gcd(b, a % b)}