From 69ab2a6ccea0601715cd4baf1e746b798b5548d6 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 20 Sep 2020 17:27:35 +0800 Subject: [PATCH] =?UTF-8?q?P1321=20=E5=8D=95=E8=AF=8D=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R38664427 --- problem/P1321/P1321.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 problem/P1321/P1321.cpp diff --git a/problem/P1321/P1321.cpp b/problem/P1321/P1321.cpp new file mode 100644 index 00000000..7c5cfab0 --- /dev/null +++ b/problem/P1321/P1321.cpp @@ -0,0 +1,22 @@ +// R38664427 + +#include + +using namespace std; + +int main() { + string s; + int boy, girl; + boy = girl = 0; + cin >> s; + + for (int i = 0; i < s.size() - 2; i++) { + boy += (s[i] == 'b' || s[i + 1] == 'o' || s[i + 2] == 'y'); + } + for (int i = 0; i < s.size() - 3; i++) { + girl += (s[i] == 'g' || s[i + 1] == 'i' || s[i + 2] == 'r' || s[i + 3] == 'l'); + } + + cout << boy << endl << girl << endl; + return 0; +}