結果
問題 | No.73 helloworld |
ユーザー |
![]() |
提出日時 | 2019-03-11 10:59:57 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,067 bytes |
コンパイル時間 | 13,249 ms |
コンパイル使用メモリ | 238,056 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 19:34:18 |
合計ジャッジ時間 | 13,978 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
package mainimport ("fmt""math")func main() {var c intalpha := make(map[string]int, 0)for i := 0; i < 26; i++ {_, _ = fmt.Scan(&c)alpha[string('a'+i)] = c}// fmt.Println(alpha)ans := 1for _, c := range "helowrd" {switch string(c) {case "h", "e", "w", "r", "d":if alpha[string(c)] < 1 {ans *= 0} else {ans *= alpha[string(c)]}case "o":if alpha[string(c)] < 2 {ans *= 0} else {p1 := int(math.Ceil(float64(alpha[string(c)]) / 2))p2 := alpha[string(c)] / 2ans *= p1 * p2}case "l":if alpha[string(c)] < 3 {ans *= 0} else {// lの確率が最大になる組み合わせを探すmax := 1for i := alpha[string(c)] - 3; i >= 0; i-- {p1 := 0for j := 1; j < i+2; j++ {p1 += j}p2 := alpha[string(c)] - 2 - i// fmt.Println(i, p1, p2)if p1*p2 > max {max = p1 * p2} else {break}}ans *= max}}// fmt.Println(string(c), alpha[string(c)], ans)}fmt.Println(ans)}