SRM427 DIV2 LoveCalculator
LOVEの各文字が何個がstringに入ってるかで相性がわかるんだってさー。
____ /⌒ ⌒\ ホジホジ /( ●) (●)\ /::::::⌒(__人__)⌒::::: \ <で? | mj |ー'´ | \ 〈__ノ / ノ ノ
#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; class LoveCalculator{ public: void countLOVE(string s, string s2, int *L, int *O, int *V, int *E) { int size = s.size(); string tmp = "LOVE"; for (int i = 0; i < size; i++){ if (s[i] == tmp[0]){ (*L) ++; }else if(s[i] == tmp[1]){ (*O) ++; }else if(s[i] == tmp[2]){ (*V) ++; }else if(s[i] == tmp[3]){ (*E) ++; } } size = s2.size(); for (int i = 0; i < size; i++){ if (s2[i] == tmp[0]){ (*L) ++; }else if(s2[i] == tmp[1]){ (*O) ++; }else if(s2[i] == tmp[2]){ (*V) ++; }else if(s2[i] == tmp[3]){ (*E) ++; } } } string findBoy(string girl, vector<string> boys) { int L = 0, O = 0, V = 0, E = 0; int size = boys.size(); int max = 0; int index = 0; vector<int> score; score.assign(size, 0); for (int i = 0; i < size; i++){ countLOVE(girl, boys[i], &L, &O, &V, &E); int tmp = ((L+O)*(L+V)*(L+E)*(O+V)*(O+E)*(V+E)) % 100; L = 0; O = 0; V = 0; E = 0; cout << boys[i] << "\t" << tmp << endl; if (max < tmp){ max = tmp; index = i; }else if(max == tmp){ if (boys[index] > boys[i]){ index = i; } } } if (max == 0){ sort(boys.begin(), boys.end()); return boys[0]; }else{ return boys[index]; } } };