結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-04-12 17:00:36 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,189 bytes |
| コンパイル時間 | 889 ms |
| コンパイル使用メモリ | 104,320 KB |
| 実行使用メモリ | 18,176 KB |
| 最終ジャッジ日時 | 2024-07-18 10:22:59 |
| 合計ジャッジ時間 | 2,665 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 WA * 1 |
コンパイルメッセージ
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 Program
{
static void Main(string[] args)
{
new Magatro().Solve();
}
}
public class Magatro
{
private long H, L;
private void Scan()
{
string[] s = Console.ReadLine().Split(' ');
H = long.Parse(s[1]);
L = long.Parse(s[0]);
}
public void Solve()
{
Scan();
int iMax = (int)Math.Sqrt(H);
long max = -1;
long ans = -1;
for (long j = iMax; j >= 2; j--)
{
if (max > j)
{
break;
}
for (long i = H / j; i >= j; i--)
{
if (i * j < L)
{
break;
}
long l = i * j;
long p = Prime(l);
if (max < p)
{
max = p;
ans = l;
}
}
}
Console.WriteLine(ans);
}
private long Prime(long l)
{
for (long i = 2; i * i <= l; i++)
{
if (l % i == 0) return i;
}
return l;
}
}
mban