結果

問題 No.509 塗りつぶしツール
ユーザー agis
提出日時 2017-04-29 00:33:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 168,620 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-13 18:53:03
合計ジャッジ時間 2,486 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	string n;
	cin >> n;
	int count1=0;
	int count2 = 0;
	for (int i = 0;i < n.size();i++) {
		if (n[i] == '0' || n[i] == '4' || n[i] == '6' || n[i] == '9') {
			count1 += 3;
		}
		else if (n[i] == '8') {
			count1 += 4;
		}
		else {
			count1 += 2;
		}
	}
	count1++;
	for (int i = 0;i < n.size();i++) {
		if (n[i] == '0' || n[i] == '4' || n[i] == '6' || n[i] == '9') {
			count2 += 3;
		}
		else if (n[i] == '8') {
			count2 += 5;
		}
		else {
			count2 += 1;
		}
	}
	count2+=2;
	cout << min(count1, count2) << endl;
	return 0;
}
0