結果
| 問題 | No.2920 Blood Type | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-10-12 15:17:56 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 1,058 bytes | 
| コンパイル時間 | 532 ms | 
| コンパイル使用メモリ | 65,024 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 15:17:58 | 
| 合計ジャッジ時間 | 1,449 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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;
}
            
            
            
        