結果
問題 | No.740 幻の木 |
ユーザー |
![]() |
提出日時 | 2018-10-05 21:38:11 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,702 bytes |
コンパイル時間 | 15,771 ms |
コンパイル使用メモリ | 242,364 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 12:56:45 |
合計ジャッジ時間 | 16,351 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
package mainimport ("bufio""fmt""log""os""strconv")func main() {log.SetFlags(log.Lshortfile)N := nextInt()M := nextInt()P := nextInt()Q := nextInt()mouth := 0for N > 0 {mouth++m := mouth % 12if m == 0 {m = 12}if m >= P && m < P+Q {N -= M * 2} else {N -= M}// log.Println(mouth, N)}fmt.Println(mouth)}func max(a ...int) int {r := a[0]for i := 0; i < len(a); i++ {if r < a[i] {r = a[i]}}return r}func min(a ...int) int {r := a[0]for i := 0; i < len(a); i++ {if r > a[i] {r = a[i]}}return r}func sum(a []int) (r int) {for i := range a {r += a[i]}return r}func minmax(a, b int) (int, int) {if a > b {return b, a}return a, b}func abs(a int) int {if a < 0 {return -a}return a}type Pair struct {a, b int}type Pairs []Pairfunc (p Pairs) Len() int {return len(p)}func (p Pairs) Swap(i, j int) {p[i], p[j] = p[j], p[i]}func (p Pairs) Less(i, j int) bool {return p[i].b < p[j].b}var nextReader func() stringfunc init() {nextReader = NewScanner()}func NewScanner() func() string {r := bufio.NewScanner(os.Stdin)r.Buffer(make([]byte, 1024), int(1e+11))r.Split(bufio.ScanWords)return func() string {r.Scan()return r.Text()}}func nextString() string {return nextReader()}func nextInt64() int64 {v, _ := strconv.ParseInt(nextReader(), 10, 64)return v}func nextInt() int {v, _ := strconv.Atoi(nextReader())return v}func nextInts(n int) []int {r := make([]int, n)for i := 0; i < n; i++ {r[i] = nextInt()}return r}func nextFloat64() float64 {f, _ := strconv.ParseFloat(nextReader(), 64)return f}