2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AtCoder Regular Contest #001 A - センター試験

Last updated at Posted at 2012-04-16

概要

センター試験で全部同じ選択肢を選んだ場合の最高得点と最低得点を回答する
正答が「1223334444」なら最高は4点、最低は1点

解いた方針

正答は文字列で与えられるので、単にpreg_match_allした

自分の回答.php

<?php
 
fscanf(STDIN, "%d", $q);
fscanf(STDIN, "%s", $answer);
 
 
 
$resultArray = array(
	preg_match_all('/1/', $answer, $matches),
	preg_match_all('/2/', $answer, $matches),
	preg_match_all('/3/', $answer, $matches),
	preg_match_all('/4/', $answer, $matches)
);
 
echo max($resultArray).' '.min($resultArray)."\n";
 
 
?>

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?