結果
| 問題 |
No.36 素数が嫌い!
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2020-09-07 13:39:29 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,066 bytes |
| コンパイル時間 | 3,537 ms |
| コンパイル使用メモリ | 112,524 KB |
| 実行使用メモリ | 94,632 KB |
| 最終ジャッジ日時 | 2024-11-29 10:34:40 |
| 合計ジャッジ時間 | 165,845 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 RE * 1 TLE * 2 |
| other | AC * 1 RE * 1 TLE * 24 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using System;
public class Hello
{
static void Main()
{
var n = long.Parse(Console.ReadLine().Trim());
var a = GeneratePrime((int)Sqrt(n));
getAns(n, a);
}
static void getAns(long n, List<int> a)
{
var count = 0;
foreach (var x in a)
{
while (true)
{
if (n % x == 0)
{
count++;
n /= x;
}
if (count >= 3) { Console.WriteLine("YES"); return; }
}
}
Console.WriteLine("NO");
}
static List<int> GeneratePrime(int m)
{
var a = new List<int>();
int p;
var sqrtMax = Math.Sqrt(m);
var s = Enumerable.Range(2, m - 1).ToList();
do
{
p = s.First();
a.Add(p);
s.RemoveAll(n => n % p == 0);
}
while (p < sqrtMax);
a.AddRange(s);
return a;
}
}
bluemegane