結果
問題 | No.371 ぼく悪いプライムじゃないよ |
ユーザー |
![]() |
提出日時 | 2016-05-14 00:48:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,710 bytes |
コンパイル時間 | 1,088 ms |
コンパイル使用メモリ | 107,776 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-12-30 18:06:59 |
合計ジャッジ時間 | 16,984 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 TLE * 3 |
コンパイルメッセージ
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; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int[] Er=new int[100000]; Er[0]=Er[1]=1; for(int i=2;i<100000;i++){ if(Er[i]==0)for(int j=i+i;j<100000;j+=i)Er[j]=1; } List<long> Prim=new List<long>(); for(int i=0;i<100000;i++){ if(Er[i]==0)Prim.Add((long)i); } long ans=0; for(int i=0;i<Prim.Count;i++){ var p=Prim[i]; for(long j=(H/p);(j>=2 && j*p>=L && p<=j);j--){ bool chk=true; for(int k=0;Prim[k]<p;k++){ if(j%Prim[k]==0){ chk=false;break; } } if(chk){ //Console.WriteLine("p={0},j={1},ans={2}",p,j,ans); ans=j*p; break; } //if(j*p<ans)break; } } Console.WriteLine(ans); } long L,H; public Sol(){ var d=rla(); L=d[0];H=d[1]; } static bool IsPrime(long x){ if(x<=1)return false; if(x==2)return true; for(long j=3;j*j<=x;j+=2){ if(x%j==0)return false; } return true; } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);} static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }