夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

過去問っていいよね

ReversedSum

今日のするめの直前にやったやつ
めんどい

class ReversedSum {
public:
   int toInt(string st) {
	   stringstream ss;
	   ss.str(st);
	   int res;
	   ss >> res;
	   return res;
   }
   string toStr(int num) {
	   stringstream ss;
	   ss << num;
	   return ss.str();
   }
	int getReversedSum( int x, int y ) {
		string revx, revy, revsum;
		revx = toStr(x);
		revy = toStr(y);
		reverse(revx.begin(), revx.end());
		reverse(revy.begin(), revy.end());
		int rx, ry;
		rx = toInt(revx);
		ry = toInt(revy);
		revsum = toStr(rx + ry);
		reverse(revsum.begin(), revsum.end());
		return toInt(revsum);
   }
};

CompositeSmash

この前のMediumだね。。。
問題理解して一生懸命自力で解いたの。。。練習べやで75点とったけどw

class CompositeSmash {
public:
	string thePossible( int N, int target ) {
		if (N < target) return "No";
		if (N == target) return "Yes";
		bool flag = true;
		vp list = smash(N);
		if (list.size() == 0) return "No";
		for (int i=0; i<list.size(); i++) {
			if (thePossible(list[i].first, target)=="No"&&
					thePossible(list[i].second, target)=="No")
				flag = false;
		}
		if (flag) return "Yes";
		else return "No";
	}
	vp smash(int n) {
		vp list;
		for (int i=2; i*i<n+1; i++) {
			if (n % i == 0) {
				list.push_back(make_pair(i, n/i));
			}
		}
		return list;
	}
};