結果
問題 |
No.2417 Div Count
|
ユーザー |
![]() |
提出日時 | 2023-08-19 10:18:11 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 797 bytes |
コンパイル時間 | 912 ms |
コンパイル使用メモリ | 113,456 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-11-29 01:45:08 |
合計ジャッジ時間 | 3,376 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 41 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math; using System.Collections.Generic; using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = long.Parse(line[0]); var k = long.Parse(line[1]); getAns(n, k); } static void getAns(long n, long k) { var c = getDiv(n - k); var ans = 0; foreach (var x in c) if (n % x == k) ans++; Console.WriteLine(ans); } public static List<long> getDiv(long n) { var ans = new List<long>(); for (int i = 1; i <= Sqrt(n); i++) { if (n % i == 0) { ans.Add(i); if (n != i * i) ans.Add(n / i); } } return ans; } }