結果
| 問題 |
No.2920 Blood Type
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 15:16:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,058 bytes |
| コンパイル時間 | 653 ms |
| コンパイル使用メモリ | 68,892 KB |
| 最終ジャッジ日時 | 2025-02-24 17:58:24 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
#include<iostream>
using namespace std;
string comb (char a, char b){
if(a=='A' && (b=='A' || b== 'O') || ((a== 'O') && (b== 'A'))) return "A";
if((a=='A' && b=='B') || (a=='B' && b =='A')) return "AB";
if(a=='B' && (b=='B' || b=='O') || ((a=='O') &&(b=='B'))) return "B";
if(a=='O' && b=='O') return "O";
else return "";
}
int main(){
string s,t;
cin>>s>>t;
// Initialize the count variables
int ca = 0, cb = 0, cab = 0, co = 0; // saare ko hi krna hai initialise, wo equal krdena tha ye to
// Loop through each character in the strings
for (int i = 0; i < s.size(); i++) {
for (int j = 0; j < t.size(); j++) {
string result = comb(s[i], t[j]); // Store the result of comb function
if (result == "A") ca++;
else if (result == "B") cb++;
else if (result == "AB") cab++;
else if (result == "O") co++;
}
}
// Calculate the probabilities in percentages
cout << ca * 25 << " " << cb * 25 << " " << cab * 25 << " " << co * 25;
return 0;
}