LoginSignup
5
1

More than 3 years have passed since last update.

"感度3000倍問題"を解いてみた

Last updated at Posted at 2019-12-25

1577225441746.jpg

twitterで見かけたこの問題が、競技プログラミング的(AtCoderの300点問題くらい)だと感じたのでc++で解いてみた。


using namespace std;

int main(int argc, char *argv[])
{
    //init
    string orc = "ABCDE";
    sort(orc.begin(), orc.end());

    //calc
    while (next_permutation(orc.begin(), orc.end())){
        int kando = 0;
        for (size_t i = 0; i < orc.length(); i++){
            char drug = orc[i];
            switch (drug){
            case 'A':
                kando /= 2;
                break;

            case 'B':
                kando -= 900;
                break;

            case 'C':
                kando += 2000;
                break;

            case 'D':
                kando *= 5;
                break;

            case 'E':
                kando += 500;
                break;

            }
        }

        if (kando == 3000){
            cout << orc << endl;
        }
    }

    return 0;
}
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1