Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a380e80

Browse files
feat: solve AtCoder questions
1 parent ea64dc0 commit a380e80

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

‎Atcoder/PHP/311.ABC/A.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
fscanf(STDIN, "%d", $n);
3+
fscanf(STDIN, "%s", $s);
4+
5+
$countA = 0;
6+
$countB = 0;
7+
$countC = 0;
8+
9+
foreach (str_split($s) as $i => $ch) {
10+
if ($ch === 'A') $countA++;
11+
elseif ($ch === 'B') $countB++;
12+
elseif ($ch === 'C') $countC++;
13+
if ($countA > 0 && $countB > 0 && $countC > 0) {
14+
$pos = $i;
15+
break;
16+
}
17+
}

‎Atcoder/PHP/312.ABC/A.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
fscanf(STDIN, "%s", $s);
3+
4+
$judge = preg_match('/^(?:ACE|BDF|CEG|DFA|EGB|FAC|GBD)$/i', strtoupper(trim($s)));
5+
6+
if ($judge == true) {
7+
echo "Yes";
8+
} else {
9+
echo "No";
10+
}

‎Atcoder/PHP/313.ABC/A.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
fscanf(STDIN, "%s", $s);
3+
$A = array_map('intval', preg_split('/\s+/', trim(fgets(STDIN))));
4+
5+
$tg = $A[0];
6+
$others = array_slice($A, 1);
7+
8+
if (empty($others)) {
9+
echo 0;
10+
exit;
11+
}
12+
13+
$max = max($others);
14+
$need = max(0, ($max - $tg) + 1);
15+
16+
echo $need;

‎Atcoder/PHP/350.ABC/A.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
fscanf(STDIN, "%s", $s);
3+
4+
if ($s === 'ABC316' || $s === 'ABC000') {
5+
echo "No";
6+
exit;
7+
}
8+
9+
$arrS = str_split($s, 3);
10+
if (intval($arrS[1]) < 350) {
11+
echo "Yes";
12+
} else {
13+
echo "No";
14+
}

‎Atcoder/PHP/351.ABC/A.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
$A = array_map('intval', preg_split('/\s+/', trim(fgets(STDIN))));
3+
$B = array_map('intval', preg_split('/\s+/', trim(fgets(STDIN))));
4+
5+
$sumA = array_sum($A);
6+
$sumB = array_sum($B);
7+
8+
$needScore = 0;
9+
10+
for($i=$sumB;$i<$sumA;$i++) {
11+
if ($i < $sumA) {
12+
$needScore ++ ;
13+
}
14+
}
15+
echo $needScore +1;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /