28日目:Begineer 44
28日目(2019/9/15)
AtCoder Beginner Contest 044
解けた問題
A: 高橋君とホテルイージー / Tak and Hotels (ABC Edit)
K日目を超えているかで分岐しました!
if(N<K){ cout << X*N; }else{ cout << X*K + Y*(N-K); }
B:美しい文字列 / Beautiful Strings
char
型から'a'
を引くと何文字目かが取れる、ということを利用して、アルファベットの数をカウント、全部ループして確認しました。
// C++のテンプレート #include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std; int main(void){ int alp[26] = {}; string w; cin >> w; for(int i=0;i<w.size();i++){ alp[w[i]-'a']++; } bool tf=true; for(int i=0;i<26;i++) if(alp[i]%2==1){ tf=false; break; } if(tf) cout << "Yes" << endl; else cout << "No" << endl; }