public static void Main()
int similationCount = 1000000;
Random rand = new Random();
int minNumberOfGuarantees = 16;
int maxNumberOfGuarantees = 30;
for (int numberOfGuarantees = minNumberOfGuarantees; numberOfGuarantees<=maxNumberOfGuarantees; numberOfGuarantees++)
int[] countsOfWeaponA = new int[numberOfGuarantees + 1];
for (int count =0; count < similationCount; count++)
bool enteringFirstGuarantee = true;
for (int i =0; i < numberOfGuarantees; i++)
if(enteringFirstGuarantee)
bool isUpWeapon = FirstGuarantee(ref weaponA, ref weaponB, ref otherWeapon, ref rand);
enteringFirstGuarantee = false;
SecondGuarantee(ref weaponA, ref weaponB, ref rand);
enteringFirstGuarantee = true;
countsOfWeaponA[weaponA] ++;
decimal moreThanOnePercentage = 100-Convert.ToDecimal(countsOfWeaponA[0])*100/similationCount;
Console.WriteLine("触发{0}次保底时", numberOfGuarantees);
Console.WriteLine("抽到1把或以上:{0:0.00}%", moreThanOnePercentage);
if(numberOfGuarantees >= 5) {
decimal lessThanFivePercentage = Convert.ToDecimal(countsOfWeaponA[0] + countsOfWeaponA[1] + countsOfWeaponA[2] + countsOfWeaponA[3] + countsOfWeaponA[4]);
lessThanFivePercentage = 100-lessThanFivePercentage*100/similationCount;
Console.WriteLine("抽到5把或以上:{0:0.00}%\n\r",lessThanFivePercentage);
private static bool FirstGuarantee(ref int weaponA, ref int weaponB, ref int otherWeapon, ref Random rand){
double weaponAProbability = 37.5d;
double weaponBProbability = 37.5d;
int chance = rand.Next(1, 101);
if (chance <= weaponAProbability)
else if (chance <= weaponAProbability + weaponBProbability)
private static void SecondGuarantee(ref int weaponA, ref int weaponB, ref Random rand) {
double weaponAProbability = 50d;
int chance = rand.Next(1, 101);
if (chance <= weaponAProbability)