File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "bufio"
5
+ . "fmt"
6
+ "io"
7
+ "math"
8
+ )
9
+
10
+ // github.com/EndlessCheng/codeforces-go
11
+ func CF230B (_r io.Reader , _w io.Writer ) {
12
+ in := bufio .NewReader (_r )
13
+ out := bufio .NewWriter (_w )
14
+ defer out .Flush ()
15
+ const mx int = 1e6
16
+ np := [mx + 1 ]bool {1 : true }
17
+ for i := 2 ; i <= mx ; i ++ {
18
+ if ! np [i ] {
19
+ for j := 2 * i ; j <= mx ; j += i {
20
+ np [j ] = true
21
+ }
22
+ }
23
+ }
24
+
25
+ var n , v int64
26
+ for Fscan (in , & n ); n > 0 ; n -- {
27
+ Fscan (in , & v )
28
+ rt := int64 (math .Sqrt (float64 (v )))
29
+ if rt * rt == v && ! np [rt ] {
30
+ Fprintln (out , "YES" )
31
+ } else {
32
+ Fprintln (out , "NO" )
33
+ }
34
+ }
35
+ }
36
+
37
+ //func main() { CF230B(os.Stdin, os.Stdout) }
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "github.com/EndlessCheng/codeforces-go/main/testutil"
5
+ "testing"
6
+ )
7
+
8
+ // https://codeforces.com/problemset/problem/230/B
9
+ // https://codeforces.com/problemset/status/230/problem/B
10
+ func TestCF230B (t * testing.T ) {
11
+ // just copy from website
12
+ rawText := `
13
+ inputCopy
14
+ 4
15
+ 4 5 6
16
+ outputCopy
17
+ YES
18
+ NO
19
+ NO`
20
+ testutil .AssertEqualCase (t , rawText , 0 , CF230B )
21
+ }
You can’t perform that action at this time.
0 commit comments