結果
問題 | No.8079 アルベド |
ユーザー |
|
提出日時 | 2021-04-02 10:16:24 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 652 bytes |
コンパイル時間 | 2,363 ms |
コンパイル使用メモリ | 107,520 KB |
実行使用メモリ | 33,536 KB |
最終ジャッジ日時 | 2024-12-23 02:54:49 |
合計ジャッジ時間 | 30,012 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 TLE * 7 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using System.Collections.Generic;using System.Linq;class G{static void Main() => Console.WriteLine(Solve());static object Solve(){var t = int.Parse(Console.ReadLine());var ns = Array.ConvertAll(new bool[t], _ => int.Parse(Console.ReadLine()));var ps = GetPrimes(ns.Max());return string.Join("\n", ns.Select(n => ps.TakeWhile(p => p <= n).Count()));}static int[] GetPrimes(int n){var b = new bool[n + 1];for (int p = 2; p * p <= n; ++p) if (!b[p]) for (int x = p * p; x <= n; x += p) b[x] = true;var r = new List<int>();for (int x = 2; x <= n; ++x) if (!b[x]) r.Add(x);return r.ToArray();}}