結果

問題 No.1330 Multiply or Divide
ユーザー aru aruaru aru
提出日時 2021-01-09 18:48:40
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,889 bytes
コンパイル時間 12,519 ms
コンパイル使用メモリ 217,584 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-04-29 07:37:27
合計ジャッジ時間 14,852 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
9,216 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 12 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 30 ms
7,424 KB
testcase_09 AC 28 ms
6,272 KB
testcase_10 AC 28 ms
7,424 KB
testcase_11 AC 30 ms
7,424 KB
testcase_12 AC 29 ms
7,424 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 29 ms
9,216 KB
testcase_19 AC 30 ms
9,216 KB
testcase_20 AC 30 ms
9,216 KB
testcase_21 AC 30 ms
9,216 KB
testcase_22 AC 29 ms
9,216 KB
testcase_23 WA -
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 22 ms
6,656 KB
testcase_35 AC 7 ms
5,376 KB
testcase_36 AC 20 ms
6,528 KB
testcase_37 AC 18 ms
6,016 KB
testcase_38 AC 12 ms
5,376 KB
testcase_39 AC 8 ms
5,376 KB
testcase_40 AC 10 ms
5,376 KB
testcase_41 AC 5 ms
5,376 KB
testcase_42 AC 17 ms
5,888 KB
testcase_43 AC 19 ms
6,016 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func getI() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	N, M, P := getI(), getI(), getI()
	a := getInts(N)
	b := make([]int, 0)
	maxB := -1
	for i := 0; i < N; i++ {
		if a[i]%P != 0 {
			b = append(b, a[i])
			maxB = max(maxB, a[i])
		}
	}
	// out(b, maxB, M)
	if maxB == -1 {
		out(-1)
		return
	}
	x := 1
	ans := 0
	for x < M {
		if x > M/maxB {
			ans++
			break
		}
		x *= maxB
		ans++
	}
	out(ans)
}
0