結果

問題 No.537 ユーザーID
ユーザー kimnykimny
提出日時 2017-12-10 21:49:18
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 1,588 bytes
コンパイル時間 3,556 ms
コンパイル使用メモリ 103,680 KB
実行使用メモリ 18,432 KB
最終ジャッジ日時 2024-11-30 11:23:43
合計ジャッジ時間 4,053 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukicoder_537 {
    class Program {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());
            long count = 0;
            for(int i = 1; i <= Math.Sqrt(n); i++) {
                if (n % i == 0) {
                    count++;
                }
            }
            long[,] a = new long[count, 2];
            for(int i = 0; i < count; i++) {
                if (i == 0) {
                    a[i, 0] = 1;
                    a[i, 1] = n;
                } else {
                    for (long k = a[i - 1, 0] + 1; k <= Math.Sqrt(n); k++) {
                        if (n % k == 0) {
                            a[i, 0] = k;
                            a[i, 1] = n / k;
                            break;
                        }
                    }
                }
            }
            string[] s = new string[count * 2];
            for(int i = 0; i < count; i++) {
                s[i * 2] = a[i, 0].ToString() + a[i, 1].ToString();
                s[i * 2 + 1] = a[i, 1].ToString() + a[i, 0].ToString();
            }
            long total = count*2;
            for(int i = 0; i < count * 2 - 1; i++) {
                for(int k = i + 1; k < count * 2; k++) {
                    if (s[i].Equals(s[k])) {
                        total--;
                    }
                }
            }
            
            Console.WriteLine(total);
            Console.ReadLine();
        }
    }
}
0