結果

問題 No.509 塗りつぶしツール
ユーザー hanorver
提出日時 2017-04-28 23:15:02
言語 C++14
(gcc 9.3.0)
結果
AC  
実行時間 4 ms
コード長 3,754 Byte
コンパイル時間 576 ms
使用メモリ 3,436 KB
最終ジャッジ日時 2020-01-24 08:24:07

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
00_sample0.txt AC 4 ms
3,208 KB
00_sample1.txt AC 0 ms
3,284 KB
00_sample2.txt AC 0 ms
3,296 KB
10_gen_case1.txt AC 4 ms
3,368 KB
10_gen_case2.txt AC 0 ms
3,368 KB
10_gen_case3.txt AC 4 ms
3,376 KB
10_gen_case4.txt AC 0 ms
3,376 KB
10_gen_case5.txt AC 4 ms
3,252 KB
10_gen_case6.txt AC 4 ms
3,304 KB
10_gen_case7.txt AC 0 ms
3,388 KB
10_gen_case8.txt AC 4 ms
3,364 KB
10_gen_case9.txt AC 0 ms
3,296 KB
10_gen_case10.txt AC 4 ms
3,292 KB
10_gen_case11.txt AC 0 ms
3,348 KB
10_gen_case12.txt AC 4 ms
3,296 KB
10_gen_case13.txt AC 0 ms
3,272 KB
10_gen_case14.txt AC 4 ms
3,272 KB
10_gen_case15.txt AC 0 ms
3,248 KB
10_gen_case16.txt AC 4 ms
3,388 KB
10_gen_case17.txt AC 0 ms
3,292 KB
10_gen_case18.txt AC 4 ms
3,300 KB
10_gen_case19.txt AC 0 ms
3,272 KB
10_gen_case20.txt AC 4 ms
3,288 KB
20_handmade1.txt AC 0 ms
3,252 KB
20_handmade2.txt AC 4 ms
3,436 KB
20_handmade3.txt AC 0 ms
3,272 KB
20_handmade4.txt AC 4 ms
3,420 KB
99_corner1.txt AC 0 ms
3,304 KB
99_corner2.txt AC 4 ms
3,248 KB
99_corner3.txt AC 0 ms
3,276 KB
テストケース一括ダウンロード

ソースコード

diff #
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <numeric>


/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::'''```````:::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::''`_,-''.,...  `::::::::::::::::::
:::::::::::::::::::::::::::::::::::::' _,-',;;!!!!!!!!!; `::::::::::::::::
::::::::::::::'`````:::::::::::::'' .-' ;<!!!!!!!'''`_..' `:::::::::::::::
::::::::::'' ,;!!!;,`::::::::::' .-`.,,,zcccc,,cccd$$"",;> `::::::::::::::
:::::::::' ;!!!!!!!!; ``:::::' ;' ,c$$$$$$$$$$$CC<<"  ````_ ::::::::::::::
:::::::' ;!!!!!!!!!!!!!;   ' ;! z$$$$$$$$$$$$$$$$$$$$$$??". ::::::::::::::
::::::: <!!!!!!!!!!!!!' .  .!',c$$$$$$$$$$$$$c, `"""',;;<!! ::::::::::::::
:::::: ,!!!!!!!!!!!'`,;! .<! ,$$$$$$$$$$$$$$$$hc,,,..- !!!! `:::::::::::::
::::'  <!!!!!!!!!' .<!!!;!! ,$$$$$""???$$$"""?????"" .<!!!! ::::::::::::::
::: ;><!!!!!!!!! ,<!!!!!!!',c,  "??.< . "??h. -;;;;!!!!!!!' ::::::::::::::
::: !!!!!!!!!!' ;!!!!!!!!' d$$h.`$ccr,$h `;,."  `!!!!!!!!! :::::::::::::::
:::.`<!!!!!!!' !!!!!!!!!! dP"""?.`$$F`$$h.`!!!!!!!!!!!!!! .:::::::::::::::
::::. <!!!!!! !!!!!!!!!! ,$ .nn.' "$$ P"   <!!!!!!!!!!!' .::::::::::::::::
:::::. <!!!! ;!!!!!!!!!! $$ MMMMx  ?$  ,dx `!!!!!!!!!!' ::::::::::::::::::
```:::: `!!! !!!'!!!!!!  `$ MMMMMM, $r MMMr !!!!!!!!' .:::::::::::::::::::
`!!;,.`' ``' ``,;!!!!' ch." 4MMMMMM "$ 4MMM `!!!!!' ..::::::::::::::::::::
!!!!!'````'``<!!!'`.z$$$$.  MMMMMMb $h MMM `!!''  .:::::::::::::::::::::::
..``.,d$$$$$c,,,. $$$$$F"?  "MMMMMM $$ 4P" '  . ::::::::::::::::::::::::::
dM""..""?$$$$$$$$$$$$$$$$$$c  "MM"   $$>`   ,c  `:::::::::::::::::::::::::
MMn.`"?hc,d$$$$$$$$$$$$$$$$$$. `P    $P'   -??P== `:::::::::::::::::::::::
MMMMMnx`"?$$$$$$$$$$$P".,.`"??$ccccc$.z$$$$.  `' .:::::::::::::::::'    ''
MMMMMM,' .?$$$$$$$$$$ d$$$    d$$$$$$$$$$$$$h..``::::::::::::::::'
MMMMMMMn `?$$$$$$$$$$,.?$$h. =."?$$$$$$$$$$$$$$hc,.``'::::::::::'
MMMMMMMM ;, `"??$$$$$$h  ?$$h. -m,``""??$$$$$$$$$$$$$c,.``````'
MMMMMMM> !!! ?cc,.,d$$$$h.`"?$hc   `P  .`"?$$$$$$$$$$$$$$$$$$$          .:
MMMMMMM ,!!'. $$$$$$$$$??=== `"""=c, " P  n. "$$$$$$$$$$$$$$$$c_    ,.::::
MMMMMMP !!! Mr<$$$$"".,c,;M ;<!! ..""=_ ' 4 .br .`""??$$$$$$$$??"".:::::::
MMMMMM';!!',M>'$$$$$$$$$>4M `!!! 4MMbn.`"=cc," -'P",c=.,.`.. .=  :::::::::
MMMMM' !!! dMb $$$$$$$$P MM> !!! 4MMMMMMr :..`"-._""Pr4"'-P" .,.`:::::::::
MMMM' <!!!,MMM "$$$$$$P dMM>;!!! 4MMMMMMb :::::.. "-=cczyycc??" .:::::::::
MMMP <!!! dMMMb "?$$P" uMMM>;!!! 4MMMMMMMr`:::::::::.........:::::::::::::
MMP';!!! ;MMMMMMn,.".uMMMMM ;!!! MMMMMMMMM,`::::::::::::::::::::::::::::::
MM ;!!!! MMMMMMMMMMMMMMMMMM !!!! MMMMMMMMMb `:::::::::::::::::::::::::::::
M" !!!! uMMMMMMMMMMMMMMMMMP !!! ;MMMMMMMMMMx :::::::::::::::::::::::::::::
P.!!!! ,MMMMMMMMMMMMMMMMMM ,!!! MMMMMMMMMMMMx`::::::::::::::::::::::::::::
!!!!> MMMMMMMMMMMMMMMMMMP !!!',MMMMMMMMMMMMM `:::::::::::::::::::::::::::
*/


long long pattern1(std::string s) {
	long long ans = 0;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '0' || s[i] == '4' || s[i] == '6' || s[i] == '9') {
			ans++;
		} else if (s[i] == '8') {
			ans += 2;
		}
	}

	ans += s.length() * 2;

	ans++;

	return ans;
}

long long pattern2(std::string s) {
	long long ans = 0;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '0' || s[i] == '4' || s[i] == '6' || s[i] == '9') {
			ans+=2;
		} else if (s[i] == '8') {
			ans += 4;
		}
	}

	ans += 2;

	ans += s.length();

	return ans;
}

int main() {
	std::string s;

	std::cin >> s;

	std::cout << std::min(pattern1(s), pattern2(s)) << std::endl;

	return 0;
}
0