結果
問題 | No.726 Tree Game |
ユーザー |
![]() |
提出日時 | 2018-08-24 22:11:27 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 2,124 bytes |
コンパイル時間 | 16,744 ms |
コンパイル使用メモリ | 221,780 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 07:39:35 |
合計ジャッジ時間 | 17,090 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
package mainimport ("bufio""bytes""fmt""log""os""strconv")// const abcd = "abcdefghijklmnopqrstuvwxyz"// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"var dr = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}var dc = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}func isPrime(n int) bool {if n == 0 {panic("n need 0")}if n == 1 {return false}if n == 2 {return true}for i := 2; i*i <= n; i++ {if n%i == 0 {return false}}return true}func main() {log.SetFlags(log.Lshortfile)nextReader = NewScanner()Y := nextInt()X := nextInt()cnt := 0if !isPrime(X) {for y := Y + 1; ; y++ {if !isPrime(y) {cnt++} else {break}}}if !isPrime(Y) {for x := X + 1; ; x++ {if !isPrime(x) {cnt++} else {break}}}if cnt%2 == 0 {fmt.Println("Second")} else {fmt.Println("First")}}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}func printInts(out []int, str string) {var bb bytes.Bufferfor i := range out {bb.WriteString(strconv.Itoa(out[i]))bb.WriteString(str)}fmt.Println(bb.String())}var nextReader func() stringfunc 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}