10만사이클 시행 40회


천장,10회확정 확률 전부 표기확률에 포함되있다고 가정하고

그냥 노천장 노확정 10만 사이클 때려박음


#include <iostream>

#include <cstdlib>

#include <ctime>


int main() {

    // 시드값 초기화

    std::srand(static_cast<unsigned int>(std::time(nullptr)));


    // 상수 정의

    const double weaponProbability = 2.487;

    const double relicProbability = 14.586;

    const int cycles = 100000;


    int totalAttempts = 0;


    for (int i = 0; i < cycles; ++i) {

        int attempts = 0;


        // 무기를 얻을 때까지 계속해서 가차를 시행

        while (true) {

            ++attempts;

            double randomValue = static_cast<double>(std::rand()) / RAND_MAX * 100.0;


            if (randomValue <= weaponProbability) {

                // 무기 획득

                break;

            }

            else if (randomValue <= weaponProbability + relicProbability) {

                // 성흔 획득

                // 근데 여기서는 아무 처리를 하지 않음

            }

            else {

                // 꽝

                // 근데 여기서도 아무 처리를 하지 않음

            }

        }


        totalAttempts += attempts;

    }


    // 평균 가차 시행 횟수 계산 및 출력

    double averageAttempts = static_cast<double>(totalAttempts) / cycles;

    std::cout << "10만 사이클 동안의 평균 가차 시행 횟수: " << averageAttempts << std::endl;


    return 0;

}


하드코딩은 역시 chatGPT