编辑代码

# coding:utf-8
#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
import random

def simulate_wish(num_wishes):
    five_star_prob = 0.01  # 基础概率
    pity_counter = 0  # 连续未获得5星思念的次数
    guaranteed_featured = False  # 是否必定获得限定5星思念
    results = []  # 存储许愿结果
    five_star_count = 0  # 总5星思念数量
    featured_count = 0  # 限定5星思念数量
    other_count = 0  # 其他5星思念数量

    for i in range(1, num_wishes + 1):
        # 检查是否触发保底机制
        if pity_counter >= 60:
            five_star_prob = min(five_star_prob + 0.10, 1.0)  # 概率增加10%,最高100%
        
        # 判断是否获得5星思念
        if random.random() < five_star_prob:
            if guaranteed_featured or random.random() < 0.5:
                result = f"第{i}次许愿结果: 5星思念【祁煜·沉入无尽海】"
                featured_count += 1
                guaranteed_featured = False  # 重置必定获得限定
            else:
                result = f"第{i}次许愿结果: 5星思念(非本期活动限定)"
                other_count += 1
                guaranteed_featured = True  # 下一次必定获得限定
            five_star_count += 1
            results.append(result)
            five_star_prob = 0.01  # 重置概率
            pity_counter = 0  # 重置保底计数器
        else:
            pity_counter += 1  # 未获得5星思念,保底计数器+1

    # 输出许愿结果
    print("\n=== 许愿结果 ===")
    for result in results:
        print(result)

    # 汇总统计
    print("\n=== 汇总统计 ===")
    print(f"总许愿次数: {num_wishes} 次")
    print(f"总5星思念数量: {five_star_count} 个")
    print(f"  - 【祁煜·沉入无尽海】: {featured_count} 个")
    print(f"  - 其他5星思念: {other_count} 个")
    print(f"触发保底机制次数: {five_star_count - (num_wishes * 0.01):.0f} 次")  # 估算保底触发次数

# 输入许愿次数
num_wishes = int(input("请输入许愿次数: "))
simulate_wish(num_wishes)