c++

SRM 148 DIV2 250

与えられた数字の各桁の数字の中で与えられたその数字自体を割り切れるものをカウントして返す #include <string> #include <vector> #include <sstream> using namespace std; class DivisorDigits { public: int howMany(int number) { int count = 0; string s; stringstream ss; s</sstream></vector></string>…

SRM 147 DIV2 250

A-Zで構成され、アルファベット順でN文字横にずらした文字列(ex.N=2:A=>C,B=>D)が与えられるので元の文字列を求めよという問題 #include <string> #include <vector> #include <sstream> using namespace std; class CCipher { public: string decode(string cipherText, int shift) {</sstream></vector></string>…

SRM 144 DIV2 500

Pは0または1で構成される文字列でQ[i] = P[i-1] + P[i] + P[i+1] となるような文字列Qが与えられるのでPを求めろという問題多分相当いけてないけれどこれを書くのに7〜8時間かかった。 自分への戒めも含めてここに記録しておく。 #include <string> #include <vector> #inclu</vector></string>…

SRM146 DIV2 250

1〜6の数字が5つ入った配列から同じ数字の場合は合算し、最大の数字を取り出す #include <string> #include <vector> #include <map> using namespace std; class YahtzeeScore { public: int maxPoints(vector <int> toss) { map<int, int> score; int i, max; max = 0; for (i=0; i<5; i++) { s</int,></int></map></vector></string>…

SRM145 DIV2 250

文字列ditheredに含まれる文字が文字列の配列screenにいくつあるかを数える問題 (英文ではよく意味が分からずぐぐった)普通にぐるぐる回しただけ #include <string> #include <vector> using namespace std; class ImageDithering { public: int count(string dithered, vect</vector></string>…