結果

問題 No.414 衝動
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-20 11:34:00
言語 Go
(1.22.1)
結果
AC  
実行時間 17 ms / 1,000 ms
コード長 450 bytes
コンパイル時間 11,368 ms
コンパイル使用メモリ 232,808 KB
実行使用メモリ 11,740 KB
最終ジャッジ日時 2024-04-27 08:36:54
合計ジャッジ時間 12,283 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
9,688 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 15 ms
11,736 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 16 ms
11,740 KB
testcase_06 AC 16 ms
11,736 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 9 ms
7,636 KB
testcase_09 AC 17 ms
11,740 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

func main() {
	var m int
	_, _ = fmt.Scan(&m)

	nums := make([]int, int(math.Ceil(math.Sqrt(float64(m))))+1) // 0が素数という扱い
	// fmt.Println(len(nums))
	nums[0] = 1
	nums[1] = 1

	for i, v := range nums {
		if v == 1 {
			continue
		}

		if m%i == 0 {
			fmt.Printf("%d %d\n", i, m/i)
			return
		}

		for j := i + i; j < len(nums); j += i {
			nums[j] = 1
		}
	}

	fmt.Printf("%d %d\n", 1, m)
}
0