結果
問題 | No.864 四方演算 |
ユーザー |
![]() |
提出日時 | 2021-05-05 18:57:22 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 37 ms / 1,000 ms |
コード長 | 1,123 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 111,168 KB |
実行使用メモリ | 26,076 KB |
最終ジャッジ日時 | 2024-09-13 11:57:48 |
合計ジャッジ時間 | 3,016 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic;using System;public class P{public long p { get; set; }public long q { get; set; }}public class Hello{static void Main(){var n = long.Parse(Console.ReadLine().Trim());var k = long.Parse(Console.ReadLine().Trim());var ps = getPS(k);getAns(ps, n);}static long calc(long k, long a){if (a > 2 * k + 1) return 0;if (a <= k) return a - 1;return 2 * k - a + 1;}static void getAns(List<P> ps, long k){var ans = 0L;foreach (var x in ps) ans += calc(k, x.p) * calc(k, x.q);Console.WriteLine(ans);}static List<P> getPS(long n){var ps = new List<P>();for (long i = 2; i * i <= n; i++){if (n % i == 0){if (n / i != i){ps.Add(new P { p = i, q = n / i });ps.Add(new P { p = n / i, q = i });}else ps.Add(new P { p = i, q = i });}}return ps;}}