Submission #2468705
Source Code Expand
package main
import (
"fmt"
)
func main() {
var n int
fmt.Scan(&n)
ps := Primes(55555)
i := 0
as := make([]int, n)
for _, p := range ps {
if p%5 == 1 {
as[i] = p
i++
}
if i == n {
break
}
}
fmt.Print(as[0])
for i := 1; i < n; i++ {
fmt.Print(" ", as[i])
}
fmt.Println()
}
func Primes(max int) []int {
primes := make([]int, 0)
isNotPrime := make([]bool, max+1)
isNotPrime[0] = true
isNotPrime[1] = true
n := 2
for ; n*n <= max; n++ {
if !isNotPrime[n] {
primes = append(primes, n)
for m := 2; n*m <= max; m++ {
isNotPrime[n*m] = true
}
}
}
for ; n <= max; n++ {
if !isNotPrime[n] {
primes = append(primes, n)
}
}
return primes
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Five, Five Everywhere |
| User | rankey55 |
| Language | Go (1.6) |
| Score | 400 |
| Code Size | 751 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 896 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | in01.txt, in02.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| in01.txt | AC | 2 ms | 896 KiB |
| in02.txt | AC | 2 ms | 896 KiB |
| sample_01.txt | AC | 2 ms | 896 KiB |
| sample_02.txt | AC | 2 ms | 896 KiB |
| sample_03.txt | AC | 2 ms | 896 KiB |