結果
| 問題 |
No.312 置換処理
|
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2016-09-10 22:36:02 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 115 ms / 2,000 ms |
| コード長 | 772 bytes |
| コンパイル時間 | 13,407 ms |
| コンパイル使用メモリ | 220,748 KB |
| 実行使用メモリ | 42,484 KB |
| 最終ジャッジ日時 | 2024-11-15 12:09:55 |
| 合計ジャッジ時間 | 18,018 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 45 |
ソースコード
package main
import (
"fmt"
"bufio"
"strconv"
"os"
)
func plist(in int) []int {
motos := []bool{}
for i := 0; i <= in; i++ {
motos = append(motos, true)
}
i := 2
for i*i <= in {
if motos[i] {
j := i*2
for j <= in {
motos[j] = false
j += i
}
}
i += 1
}
res := []int{}
for i := 2; i <= in; i++ {
if motos[i] {
res = append(res, i)
}
}
return res
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
N := 0
for scanner.Scan() {
N, _ = strconv.Atoi(scanner.Text())
break
}
ps := plist(10000000)
ps[0] = 3
ps[1] = 4
for _, p := range ps {
if N % p == 0 {
fmt.Println(p)
os.Exit(0)
}
}
if N%2 == 0 {
fmt.Println(N / 2)
os.Exit(0)
}
fmt.Println(N)
}
💕💖💞