結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
|
提出日時 | 2016-08-05 23:19:19 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,383 bytes |
コンパイル時間 | 2,626 ms |
コンパイル使用メモリ | 111,436 KB |
実行使用メモリ | 40,716 KB |
最終ジャッジ日時 | 2024-11-07 01:45:24 |
合計ジャッジ時間 | 7,104 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 -- * 4 |
other | -- * 31 |
コンパイルメッセージ
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; using System.Text; using System.Threading.Tasks; namespace yuki_407 { class Program { static void Main(string[] args) { var a = scan(); var k = new List<int>(); long ans = 0; int max = 10000000 / 2; var z = new int[max]; k.Add(2); for (int i = 3; i < max;i+=2) { bool t = true; for (int j = 3; j*j <=i; j++) { if (i%j==0) { t = false; break; } } if (t) { k.Add(i); } } foreach (var i in k) { if (i*(a[0]-1)>a[1]) { break; } else { int m = i * (a[0] - 1); ans += a[1] - m + 1; } } Console.WriteLine(ans); } static int[] scan() { return Array.ConvertAll (Console.ReadLine().Split(' '), int.Parse); } } }