結果
| 問題 |
No.138 化石のバージョン
|
| コンテスト | |
| ユーザー |
seaside0002
|
| 提出日時 | 2020-01-12 13:09:24 |
| 言語 | PHP (843.2) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 5,000 ms |
| コード長 | 790 bytes |
| コンパイル時間 | 2,935 ms |
| コンパイル使用メモリ | 32,148 KB |
| 実行使用メモリ | 32,656 KB |
| 最終ジャッジ日時 | 2024-11-28 20:10:54 |
| 合計ジャッジ時間 | 5,097 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
$fossilVer = trim(fgets(STDIN));
$target = trim(fgets(STDIN));
$X = new something($target);
$X->comparVer($fossilVer, $target);
if($X->status == 'OLD'){
echo 'YES';
}else if($X->status == 'NEW'){
echo 'NO';
}
class something{
public $version;
public $status;
function __construct($target){
$this->version = $target;
}
function comparVer($fossil, $tar){
$fos = explode('.', $fossil);
$t = explode('.', $tar);
if(!(count($fos) == count($t))){
die("ERROR!");
}else{
$roop = count($fos);
}
$this->status = 'OLD';
for($i = 0; $i < $roop; $i++){
if($fos[$i] == $t[$i]){
continue;
}else if($fos[$i] < $t[$i]){
$this->status = 'NEW';
return;
}else if($fos[$i] > $t[$i]){
$this->status = 'OLD';
return;
}
}
}
}
seaside0002