結果

問題 No.491 10^9+1と回文
ユーザー aru aruaru aru
提出日時 2020-10-16 11:58:59
言語 Go
(1.22.1)
結果
AC  
実行時間 151 ms / 1,000 ms
コード長 2,114 bytes
コンパイル時間 11,136 ms
コンパイル使用メモリ 201,152 KB
実行使用メモリ 20,724 KB
最終ジャッジ日時 2023-09-28 01:52:00
合計ジャッジ時間 29,105 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
20,720 KB
testcase_01 AC 143 ms
20,716 KB
testcase_02 AC 140 ms
20,720 KB
testcase_03 AC 143 ms
20,696 KB
testcase_04 AC 145 ms
20,716 KB
testcase_05 AC 142 ms
20,664 KB
testcase_06 AC 146 ms
20,696 KB
testcase_07 AC 144 ms
20,716 KB
testcase_08 AC 140 ms
20,684 KB
testcase_09 AC 142 ms
20,452 KB
testcase_10 AC 143 ms
20,720 KB
testcase_11 AC 139 ms
19,604 KB
testcase_12 AC 141 ms
19,540 KB
testcase_13 AC 145 ms
19,612 KB
testcase_14 AC 142 ms
20,648 KB
testcase_15 AC 143 ms
20,648 KB
testcase_16 AC 145 ms
20,704 KB
testcase_17 AC 144 ms
20,720 KB
testcase_18 AC 144 ms
20,692 KB
testcase_19 AC 139 ms
20,460 KB
testcase_20 AC 138 ms
20,716 KB
testcase_21 AC 144 ms
19,608 KB
testcase_22 AC 142 ms
20,696 KB
testcase_23 AC 144 ms
20,696 KB
testcase_24 AC 143 ms
20,552 KB
testcase_25 AC 139 ms
20,684 KB
testcase_26 AC 145 ms
19,608 KB
testcase_27 AC 151 ms
20,696 KB
testcase_28 AC 144 ms
20,440 KB
testcase_29 AC 143 ms
20,700 KB
testcase_30 AC 144 ms
20,672 KB
testcase_31 AC 140 ms
19,336 KB
testcase_32 AC 145 ms
19,612 KB
testcase_33 AC 140 ms
19,552 KB
testcase_34 AC 149 ms
20,692 KB
testcase_35 AC 148 ms
20,440 KB
testcase_36 AC 142 ms
20,724 KB
testcase_37 AC 143 ms
20,452 KB
testcase_38 AC 140 ms
19,544 KB
testcase_39 AC 142 ms
20,668 KB
testcase_40 AC 143 ms
20,668 KB
testcase_41 AC 144 ms
19,348 KB
testcase_42 AC 142 ms
20,688 KB
testcase_43 AC 141 ms
19,612 KB
testcase_44 AC 140 ms
20,696 KB
testcase_45 AC 144 ms
19,564 KB
testcase_46 AC 142 ms
19,324 KB
testcase_47 AC 140 ms
19,608 KB
testcase_48 AC 145 ms
20,716 KB
testcase_49 AC 140 ms
20,696 KB
testcase_50 AC 143 ms
19,348 KB
testcase_51 AC 142 ms
20,716 KB
testcase_52 AC 140 ms
20,668 KB
testcase_53 AC 139 ms
20,708 KB
testcase_54 AC 141 ms
20,484 KB
testcase_55 AC 142 ms
20,668 KB
testcase_56 AC 145 ms
19,552 KB
testcase_57 AC 144 ms
19,608 KB
testcase_58 AC 140 ms
19,552 KB
testcase_59 AC 144 ms
20,700 KB
testcase_60 AC 145 ms
20,664 KB
testcase_61 AC 143 ms
20,724 KB
testcase_62 AC 144 ms
20,720 KB
testcase_63 AC 145 ms
20,504 KB
testcase_64 AC 144 ms
19,612 KB
testcase_65 AC 145 ms
19,544 KB
testcase_66 AC 142 ms
19,600 KB
testcase_67 AC 146 ms
20,724 KB
testcase_68 AC 143 ms
19,544 KB
testcase_69 AC 142 ms
20,500 KB
testcase_70 AC 139 ms
19,544 KB
testcase_71 AC 145 ms
19,540 KB
testcase_72 AC 142 ms
19,604 KB
testcase_73 AC 147 ms
19,548 KB
testcase_74 AC 141 ms
20,712 KB
testcase_75 AC 140 ms
19,304 KB
testcase_76 AC 144 ms
20,708 KB
testcase_77 AC 149 ms
20,696 KB
testcase_78 AC 147 ms
19,612 KB
testcase_79 AC 144 ms
19,408 KB
testcase_80 AC 145 ms
19,336 KB
testcase_81 AC 139 ms
19,544 KB
testcase_82 AC 141 ms
20,668 KB
testcase_83 AC 139 ms
20,716 KB
testcase_84 AC 146 ms
20,496 KB
testcase_85 AC 140 ms
20,716 KB
testcase_86 AC 144 ms
19,556 KB
testcase_87 AC 142 ms
19,544 KB
testcase_88 AC 146 ms
19,548 KB
testcase_89 AC 142 ms
20,716 KB
testcase_90 AC 146 ms
19,556 KB
testcase_91 AC 145 ms
20,676 KB
testcase_92 AC 149 ms
19,552 KB
testcase_93 AC 141 ms
20,684 KB
testcase_94 AC 144 ms
19,608 KB
testcase_95 AC 146 ms
20,684 KB
testcase_96 AC 141 ms
20,724 KB
testcase_97 AC 143 ms
20,716 KB
testcase_98 AC 143 ms
20,672 KB
testcase_99 AC 145 ms
20,660 KB
testcase_100 AC 139 ms
20,708 KB
testcase_101 AC 140 ms
20,668 KB
testcase_102 AC 144 ms
19,600 KB
testcase_103 AC 141 ms
20,716 KB
testcase_104 AC 141 ms
20,492 KB
testcase_105 AC 146 ms
20,676 KB
権限があれば一括ダウンロードができます

ソースコード

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
}

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
}

const inf = int(1e18)
const mod = int(1e9) + 1

func f(x int) bool {
	s := strconv.Itoa(x)
	for i := 0; i < len(s); i++ {
		if s[i] != s[len(s)-1-i] {
			return false
		}
	}
	return true
}

func mk(n int) (int, int) {
	s := strconv.Itoa(n)
	s0 := s
	s1 := s
	for i := len(s) - 1; i >= 0; i-- {
		s0 += string(s[i])
		if i != len(s)-1 {
			s1 += string(s[i])
		}
	}
	r0, _ := strconv.Atoi(s0)
	r1, _ := strconv.Atoi(s1)
	return r0, r1
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cnt := 0
	m := make(map[int]int, 0)
	for {
		cnt++
		r0, r1 := mk(cnt)
		m[r0]++
		m[r1]++
		if cnt > int(1e5) {
			break
		}
	}
	a := make([]int, 0, len(m))
	for e := range m {
		a = append(a, e)
	}
	sort.Ints(a)

	N := getI()
	ans := 0
	for i := 0; i < len(a); i++ {
		x := a[i] * mod
		if x/mod != a[i] {
			break
		}
		if a[i]*mod > N {
			break
		}
		ans++
	}
	out(ans)
}
0