BUN1024

部署运行你感兴趣的模型镜像

Description

阳春三月,LiuLibo和朋友们外出郊游。午饭时间,大家都纷纷拿出自己携带的食物准备大快朵颐。LiuLibo什么都没有带,只好求大家分一点给他,可是大家为了惩罚他的懒惰,都严辞拒绝了(呜呜……>__<)。总不能就这么挨饿吧?LiuLibo灵机一动,想出一个游戏,他提出和每个朋友都玩一轮这个游戏,如果他赢了,就能从那个朋友那里分到食物,朋友们都同意了。
这个游戏是这样玩的: LiuLibo和对手各自在纸上写下一个整数,写好后,两人把纸条摆在面前,把纸上的两个数相加后除以19。然后,LiuLibo从身上拿出三个骰子,随意掷出。如果他掷出的骰子的总点数不低于他们在纸上写下的两个数除以19的余数,LiuLibo就赢了。由于深知概率论在计算机科学上有着非常重要的应用,LiuLibo以前上课的时候就把概率论学得很好。现在,每次掷骰子前,LiuLibo都想快速计算出他获胜的可能性有多大。(如果获胜的可能性太低,他就要开始想办法耍赖啦^_^)但是,没有计算机,这对他来说也非常困难,你赶快来帮帮他吧。

Input

输入的第一行是一个整数T(1 ≤ T ≤1000),表示总共玩了T回合的游戏。
以下T行每行是一组数据,每组数据中的两个整数a、b(0≤a, b≤100)表示两人在纸上写下的两个整数。

Output

对于每个回合游戏,输出这一回合中LiuLibo获胜的概率,每个答案一行。结果四舍五入,保留4位小数。

Sample Input

3
5 6
9 10
10 10

Sample Output

0.5000
1.0000
1.0000


game.py:


import string
m=[]
for j in range(3,19):
    m.append(j)
u=[1,3,6,10,15,21,25,27,27,25,21,15,10,6,3,1]
adict=dict(zip(m,u))
n=input()
for i in range(n):
    s=raw_input()
    a=string.split(s,' ')
    x=int(a[0])
    y=int(a[1])
    z=(x+y)%19
    sum1=0
    for i in m:
        if i<z:
            sum1+=adict[i]
        else:
            break
    res=float(216-sum1)/216
    print "%.4f" % res




您可能感兴趣的与本文相关的镜像

Dify

Dify

AI应用
Agent编排

Dify 是一款开源的大语言模型(LLM)应用开发平台,它结合了 后端即服务(Backend as a Service) 和LLMOps 的理念,让开发者能快速、高效地构建和部署生产级的生成式AI应用。 它提供了包含模型兼容支持、Prompt 编排界面、RAG 引擎、Agent 框架、工作流编排等核心技术栈,并且提供了易用的界面和API,让技术和非技术人员都能参与到AI应用的开发过程中

这个代码中如果最后显示我的内存不足可以调整参数让模型可以运行吗: import torch from diffusers import ZImagePipeline # 1. Load the pipeline # Use bfloat16 for optimal performance on supported GPUs pipe = ZImagePipeline.from_pretrained( "./Z-Image-Turbo", torch_dtype=torch.bfloat16, low_cpu_mem_usage=False, ) pipe.to("cuda") # [Optional] Attention Backend # Diffusers uses SDPA by default. Switch to Flash Attention for better efficiency if supported: # pipe.transformer.set_attention_backend("flash") # Enable Flash-Attention-2 # pipe.transformer.set_attention_backend("_flash_3") # Enable Flash-Attention-3 # [Optional] Model Compilation # Compiling the DiT model accelerates inference, but the first run will take longer to compile. # pipe.transformer.compile() # [Optional] CPU Offloading # Enable CPU offloading for memory-constrained devices. # pipe.enable_model_cpu_offload() prompt = "Young Chinese woman in red Hanfu, intricate embroidery. Impeccable makeup, red floral forehead pattern. Elaborate high bun, golden phoenix headdress, red flowers, beads. Holds round folding fan with lady, trees, bird. Neon lightning-bolt lamp (⚡️), bright yellow glow, above extended left palm. Soft-lit outdoor night background, silhouetted tiered pagoda (西安大雁塔), blurred colorful distant lights." # 2. Generate Image image = pipe( prompt=prompt, height=1024, width=1024, num_inference_steps=9, # This actually results in 8 DiT forwards guidance_scale=0.0, # Guidance should be 0 for the Turbo models generator=torch.Generator("cuda").manual_seed(42), ).images[0] image.save("example.png")
最新发布
12-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值