結果
問題 | No.1992 Tendon Walk |
ユーザー |
|
提出日時 | 2022-07-02 20:04:49 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 710 bytes |
コンパイル時間 | 13,862 ms |
コンパイル使用メモリ | 225,132 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 17:05:11 |
合計ジャッジ時間 | 14,428 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
package mainimport ("bufio""fmt""os""strconv")var sc = bufio.NewScanner(os.Stdin)var out = bufio.NewWriter(os.Stdout)func F(x int) int {if x == 1 {return 0}// x >= 2if x%2 == 0 {d := Max(Ceil(x, 2)-2, 0)return x + 8*d} else {return F(x+1) + 1}}func main() {buf := make([]byte, 1024*1024)sc.Buffer(buf, bufio.MaxScanTokenSize)sc.Split(bufio.ScanWords)x := nextInt()ans := F(x)PrintInt(ans)}func nextInt() int {sc.Scan()i, _ := strconv.Atoi(sc.Text())return i}func PrintInt(x int) {defer out.Flush()fmt.Fprintln(out, x)}func Max(x, y int) int {if x < y {return y}return x}func Ceil(x, y int) int {return (x + y - 1) / y}