結果

問題 No.2417 Div Count
ユーザー 木山木山
提出日時 2023-08-12 14:37:20
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 9,864 ms
コンパイル使用メモリ 235,528 KB
実行使用メモリ 10,424 KB
最終ジャッジ日時 2024-04-30 06:38:33
合計ジャッジ時間 18,428 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,424 KB
testcase_01 AC 1 ms
6,820 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 1 ms
6,944 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1 ms
6,944 KB
testcase_35 WA -
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 1 ms
6,940 KB
testcase_38 WA -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var N, K int
	ans := 1

	fmt.Fscan(in, &N, &K)
	val := N - K
	list, m := soinsu(val, K)

	//fmt.Println(list, m)
	if K == 0 {
		ans = len(m)
	} else {
		for i := 0; i < len(list); i++ {
			ans *= (m[list[i]] + 1)
			//fmt.Println(m[list[i]] + 1)
		}
		if len(list) != 1 {
			ans -= 1
		}

	}

	fmt.Println(ans)
}

func soinsu(N, K int) ([]int, map[int]int) {
	list := make([]int, 0)
	m := make(map[int]int)
	for i := K + 1; i < N; i++ {
		if i*i > N {
			break
		}
		if N%i != 0 {
			continue
		}
		for N%i == 0 {
			if _, ok := m[i]; ok {
				m[i]++
			} else {
				m[i] = 1
				list = append(list, i)
			}
			N /= i
			if i == 1 {
				break
			}
		}
	}
	if N != 1 && K < N {
		list = append(list, N)
		if _, ok := m[N]; ok {
			m[N]++
		} else {
			m[N] = 1
		}
	}
	return list, m
}
0