結果
| 問題 | No.280 歯車の問題(1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-09-17 21:04:12 |
| 言語 | Go (1.25.5) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,212 bytes |
| 記録 | |
| コンパイル時間 | 13,946 ms |
| コンパイル使用メモリ | 234,764 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-01-02 12:29:56 |
| 合計ジャッジ時間 | 14,682 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
// Scan開始前にSplitを設定しないとPanicになるため、ここに移動
s.Split(bufio.ScanWords)
N := nextInt()
// 元のコードはScanLinesとScanWordsを混在させていましたが、これはGoの仕様上Panicになります。
// そのため、nextIntArrayにNを渡し、ScanWordsのままN個の整数を読み込むように修正しました。
z := nextIntArray(N)
fmt.Print(z[N-1])
fmt.Print("/")
fmt.Print(z[0])
}
func nextIntArray(n int) []int {
// ScanLinesの使用はPanicの原因となるため、nextIntをn回呼ぶ形式に変更
data := make([]int, n)
for i := 0; i < n; i++ {
data[i] = nextInt()
}
return data
}
var s = bufio.NewScanner(os.Stdin)
func next() string {
// s.Split(bufio.ScanWords) // 削除: Scan後に呼ぶとPanicになるため
s.Scan()
return s.Text()
}
func nextLine() string {
// s.Split(bufio.ScanLines) // 削除: 同上
s.Scan()
return s.Text()
}
func nextInt() int {
i, e := strconv.Atoi(next())
if e != nil {
panic(e)
}
return i
}
func nextLong() int64 {
i, e := strconv.ParseInt(next(), 10, 64)
if e != nil {
panic(e)
}
return i
}