結果
| 問題 |
No.192 合成数
|
| コンテスト | |
| ユーザー |
明智重蔵
|
| 提出日時 | 2015-09-05 16:43:16 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,331 bytes |
| コンパイル時間 | 1,241 ms |
| コンパイル使用メモリ | 105,344 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-06-27 01:46:02 |
| 合計ジャッジ時間 | 3,988 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = "Input3";
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;
}
//No.192 合成数
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;
}
}
明智重蔵