結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
![]() |
提出日時 | 2019-04-05 00:26:25 |
言語 | Go (1.23.4) |
結果 |
MLE
|
実行時間 | - |
コード長 | 623 bytes |
コンパイル時間 | 11,505 ms |
コンパイル使用メモリ | 239,824 KB |
実行使用メモリ | 811,724 KB |
最終ジャッジ日時 | 2024-12-29 06:41:00 |
合計ジャッジ時間 | 51,632 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 WA * 1 MLE * 28 |
ソースコード
package main import "fmt" func main() { var n int _, _ = fmt.Scan(&n) // n以下のコインを洗い出す coins := make([]int, 0) for i := 1; i < n; i++ { c := i * (i + 1) / 2 if c <= n { coins = append(coins, c) } else { break } } // fmt.Println(coins) // 幅優先探索してみる pattern := []int{0} ans := 0 for ans < 10 { ans++ tmp := make([]int, 0) for _, p := range pattern { for _, c := range coins { if p+c == n { fmt.Println(ans) return } else if p+c < n { tmp = append(tmp, p+c) } } } pattern = tmp // fmt.Println(ans, pattern) } }