评论区群英荟萃
序号 | 题目 | 分数 | 通过率 | 挑战人数 | |
---|---|---|---|---|---|
19867 | 1 | 94.0% | 889 | ||
19868 | 1 | 66.6% | 686 | ||
19869 | 1 | 13.8% | 465 | ||
19860 | 1 | 71.3% | 515 | ||
19861 | 1 | 36.9% | 198 | ||
19862 | 1 | 35.6% | 59 |
排名 | 用户 | 分数 | 用时 |
---|---|---|---|
![]() | ![]() | 6 | 1小时49分钟 |
![]() | ![]() | 6 | 2小时4分钟 |
![]() | ![]() | 6 | 2小时24分钟 |
4 | 6 | 2小时43分钟 | |
5 | ![]() | 6 | 2小时51分钟 |
6 | ![]() | 6 | 3小时6分钟 |
7 | ![]() | 6 | 3小时15分钟 |
8 | ![]() | 6 | 3小时50分钟 |
9 | ![]() | 6 | 5小时18分钟 |
10 | 5 | 2小时22分钟 |
比完记得今晚21:00准时观看由出题人主讲的赛后赛题解析直播哦:http://live.bilibili.com/4798053
直播间会抽取本场的幸运儿,获得现金奖励🎁~
import random
class Gift:
"""
抽检类
"""
def __init__(self, user_count):
self.user_count = user_count
@staticmethod
def get_luck_body(start, end, count=2):
if start == end:
return [start]
luck_list = []
while len(luck_list) < count:
luck = random.randint(start, end)
if luck not in luck_list:
luck_list.append(luck)
return luck_list
def prize_draw(self):
"""
抽奖函数
"""
if self.user_count < 100:
print("抽奖人数不足100人")
return
# 4-10名,赛后直播随机抽取1人,¥100
luck_body = self.get_luck_body(4, 10, count=1)
print("第4∼10名,赛后直播随机抽取1人,¥100,中奖名单为:{luck_body}".format(luck_body=luck_body))
pre_section = [11, 100]
n = 1
while True:
section_start = 100 * pow(2, n - 1) + 1
section_end = min(100 * pow(2, n), self.user_count)
if pre_section[0] <= 100:
num_count = 4
reward_amount = 50
else:
num_count = 5
reward_amount = 20
# 如果这个周期不是满,就用这个周期的人数加上上个周期的人数去抽奖 结束循环
if section_end < 100 * pow(2, n):
section_start = pre_section[0]
luck_body = self.get_luck_body(section_start, section_end, count=num_count)
print(
"第{section_start}∼{section_end}名,每个区间,赛后直播随机抽取{num_count}名,每人¥{reward_amount},中奖名单为:{luck_body}".format(
section_end=section_end, section_start=section_start, num_count=num_count,
reward_amount=reward_amount, luck_body=luck_body))
break
# 如果这个周期是满的 则继续循环
else:
pre_section_start, pre_section_end = pre_section
luck_body = self.get_luck_body(pre_section_start, pre_section_end, count=num_count)
print(
"第{section_start}∼{section_end}名,每个区间,赛后直播随机抽取{num_count}名,每人¥{reward_amount},中奖名单为:{luck_body}".format(
section_end=pre_section_end, section_start=pre_section_start, num_count=num_count,
reward_amount=reward_amount, luck_body=luck_body))
pre_section = [section_start, section_end]
n += 1
if __name__ == '__main__':
user_count = input()
gift = Gift(int(user_count))
gift.prize_draw()
copy