結果
| 問題 |
No.8023 素数判定するだけ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-30 09:43:53 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 1,000 ms |
| コード長 | 835 bytes |
| コンパイル時間 | 1,292 ms |
| コンパイル使用メモリ | 112,476 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2024-10-04 17:02:46 |
| 合計ジャッジ時間 | 4,691 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
public class Program
{
const int one =('C'^'B');
const int zero =('A'^'A');
const int twelve=('M'^'A');
static int add(int a,int b){
int c;
while(zero!=b){
c = a&b;
a = a^b;
b = c<<one;
}
return a;
}
static int negative(int a){
return add(~a,one);
}
static int mod(int a,int d){
int q=zero,r=zero,i;
for (i=twelve;zero<=i;i=add(i,negative(one))){
r <<= one;
r |= (a>>i)&one;
if (r >= d){
r = add(r,negative(d));
q|=one<<i;
}
}
return r;
}
static void Main()
{
string s = Console.ReadLine();
int x = int.Parse(s);
int i;
if (x==one){Console.WriteLine("NO");return ;}
for (i=add(one,one);i<x;i=add(i,one)){
if (mod(x,i)==zero){Console.WriteLine("NO");return ;}
}
Console.WriteLine("YES");return ;
}
}