結果
| 問題 | 
                            No.726 Tree Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             norioc
                         | 
                    
| 提出日時 | 2018-08-25 00:30:17 | 
| 言語 | D  (dmd 2.109.1)  | 
                    
| 結果 | 
                             
                                CE
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,588 bytes | 
| コンパイル時間 | 305 ms | 
| コンパイル使用メモリ | 11,520 KB | 
| 最終ジャッジ日時 | 2024-11-14 20:35:49 | 
| 合計ジャッジ時間 | 863 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Main.d(1): Error: unable to read module `all` Main.d(1): Expected 'std/experimental/all.d' or 'std/experimental/all/package.d' in one of the following import paths: import path[0] = /opt/dmd/src/druntime/import/ import path[1] = /opt/dmd/src/phobos import path[2] = /home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd
ソースコード
import std.experimental.all;
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
bool isPrime(long n) {
    assert(n > 1);
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (long i = 3; i * i <= n; i += 2) {
        if (n % i == 0) return false;
    }
    return true;
}
int next(int n) {
    for (int i = 1; ; i++) {
        int x = n + i;
        if (isPrime(x)) {
            return i - 1;
        }
    }
}
bool isInvalid(int n) {
    if (n == 1) return false;
    return isPrime(n);
}
void calc(int y, int x) {
    void result(int n) {
        if (n % 2 == 0) writeln("Second");
        else writeln("First");
    }
    int turn = 0;
    while (true) {
        // writeln(x, " ", y);
        if (isInvalid(x) && isInvalid(y)) {
            result(turn);
            break;
        }
        if (isInvalid(x)) {
            if (isInvalid(x + 1)) {
                result(turn);
                break;
            }
            x++;
        }
        else if (isInvalid(y)) {
            if (isInvalid(y + 1)) {
                result(turn);
                break;
            }
            y++;
        }
        else {
            if (isInvalid(x + 1) && isInvalid(y + 1)) {
                result(turn);
                break;
            }
            else if (isInvalid(x + 1)) {
                y++;
            }
            else x++;
        }
        turn++;
    }
}
void main() {
    auto yx = readints;
    int y = yx[0], x = yx[1];
    calc(y, x);
}
            
            
            
        
            
norioc