結果

問題 No.1218 Something Like a Theorem
ユーザー aru aru
提出日時 2020-09-29 21:48:16
言語 Go
(1.23.4)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 1,458 bytes
コンパイル時間 14,092 ms
コンパイル使用メモリ 223,868 KB
実行使用メモリ 50,364 KB
最終ジャッジ日時 2024-07-04 13:29:43
合計ジャッジ時間 14,452 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
func out(x ...interface{}) {
fmt.Println(x...)
}
var sc = bufio.NewScanner(os.Stdin)
func getInt() int {
sc.Scan()
i, e := strconv.Atoi(sc.Text())
if e != nil {
panic(e)
}
return i
}
func getInts(N int) []int {
ret := make([]int, N)
for i := 0; i < N; i++ {
ret[i] = getInt()
}
return ret
}
func getString() 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
}
func pow(a, n int) int {
ret := 1
x := a
for n > 0 {
if n%2 == 1 {
ret *= x
}
x *= x
n /= 2
}
return ret
}
func main() {
sc.Split(bufio.ScanWords)
sc.Buffer([]byte{}, 1000000)
n, z := getInt(), getInt()
Z := pow(z, n)
m := make(map[int]bool)
for i := 1; i <= z; i++ {
x := pow(i, n)
m[x] = true
}
// out(m, Z)
// out(pow(z, n))
for x := range m {
y := Z - x
if m[y] == true {
// out(x, y, Z)
out("Yes")
return
}
}
out("No")
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0