結果
| 問題 |
No.192 合成数
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-10 23:31:41 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,309 bytes |
| コンパイル時間 | 986 ms |
| コンパイル使用メモリ | 112,408 KB |
| 実行使用メモリ | 27,792 KB |
| 最終ジャッジ日時 | 2024-10-10 23:31:44 |
| 合計ジャッジ時間 | 2,846 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
コンパイルメッセージ
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;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("101");
//4
//1,2,3はいずれも合成数ではありませんが、
//4は1,4の他に2を約数として持つため合成数です。
}
else if (InputPattern == "Input2") {
WillReturn.Add("1000");
//1000
//N自身が合成数である場合、それを出力しても正答となります
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
for (int I = N - 100; I <= N + 100; I++) {
if (IsPrime(I)) continue;
Console.WriteLine(I);
break;
}
}
//素数かを判定
static bool IsPrime(int pTarget)
{
for (int I = 2; I * I <= pTarget; I++) {
if (pTarget % I == 0) return false;
}
return true;
}
}
aketijyuuzou