結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー kuuso1kuuso1
提出日時 2016-05-14 00:48:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 962 ms / 1,000 ms
コード長 1,710 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 106,472 KB
実行使用メモリ 22,976 KB
最終ジャッジ日時 2023-08-29 00:56:22
合計ジャッジ時間 18,578 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
20,892 KB
testcase_01 AC 60 ms
20,796 KB
testcase_02 AC 61 ms
22,904 KB
testcase_03 AC 60 ms
20,864 KB
testcase_04 AC 61 ms
22,812 KB
testcase_05 AC 61 ms
22,912 KB
testcase_06 AC 61 ms
22,832 KB
testcase_07 AC 61 ms
18,744 KB
testcase_08 AC 60 ms
18,768 KB
testcase_09 AC 61 ms
20,776 KB
testcase_10 AC 61 ms
20,876 KB
testcase_11 AC 61 ms
20,868 KB
testcase_12 AC 61 ms
22,880 KB
testcase_13 AC 62 ms
22,880 KB
testcase_14 AC 64 ms
20,880 KB
testcase_15 AC 62 ms
20,788 KB
testcase_16 AC 61 ms
20,968 KB
testcase_17 AC 62 ms
22,944 KB
testcase_18 AC 61 ms
22,952 KB
testcase_19 AC 61 ms
20,748 KB
testcase_20 AC 61 ms
22,876 KB
testcase_21 AC 61 ms
22,976 KB
testcase_22 AC 77 ms
22,844 KB
testcase_23 AC 62 ms
20,832 KB
testcase_24 AC 636 ms
20,868 KB
testcase_25 AC 962 ms
22,868 KB
testcase_26 AC 61 ms
20,920 KB
testcase_27 AC 60 ms
20,904 KB
testcase_28 AC 63 ms
20,892 KB
testcase_29 AC 397 ms
20,840 KB
testcase_30 AC 905 ms
20,936 KB
testcase_31 AC 935 ms
20,928 KB
testcase_32 AC 881 ms
20,836 KB
testcase_33 AC 884 ms
21,016 KB
testcase_34 AC 760 ms
20,856 KB
testcase_35 AC 843 ms
20,892 KB
testcase_36 AC 349 ms
20,892 KB
testcase_37 AC 916 ms
18,876 KB
testcase_38 AC 773 ms
22,856 KB
testcase_39 AC 940 ms
20,932 KB
testcase_40 AC 851 ms
20,872 KB
testcase_41 AC 781 ms
22,912 KB
testcase_42 AC 690 ms
20,936 KB
testcase_43 AC 264 ms
18,752 KB
testcase_44 AC 61 ms
20,764 KB
testcase_45 AC 60 ms
20,712 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
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));}
}
0