Gym - 101864 A Criminal

A Criminal
题 意:监狱有n个人,小明的编号是x,监狱长每次随机挑选一个Y(Y属于l,n)。把1,2,3…Y。拿出来玩游戏。从第一个开始,在当前没有没惩罚的集合中,跳过第当前这个,惩罚下一个,最后只剩一个不被惩罚。输入n,x,l问小明不被惩罚的概率是多少?
数据范围:
1<=t<=10500
1<=x<=n<=1e15
1<=L<=N

输入样例:

3
1 1 1
2 3 10
4 1 7

输出样例:

Case 1: 1/1
Case 2: 0/1
Case 3: 3/7

思 路:看到范围这么大,肯定是个打表找规律的题目。打表发现每次到了2^a次方就从1开是1,3,5这样的递增。然后就是暴力分情况了。分情况的原则是经可能少,覆盖所有可能。明了简洁。
收 获:暴力姿势要优美。多学学暴力的姿势,哪怕自己a了

#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll x,l,n;
ll gcd(ll a,ll b){
    if(b == 0)return a;
    else return gcd(b,a%b);
}
int main(){
    int t,Kase=1;
    scanf("%d",&t);
    while(t--){
        scanf("%lld %lld %lld",&x,&l,&n);
        ll left=0;
        for(int i=0;i<64;i++){
            if((1ll<<i) > x){left = i-1;break;}
        }
        ll res=(x-1)/2,ans=0;
        for(int i=left;i<64;i++){
            ll temp = (1ll<<i);
            if(temp+res >=l && temp+res<=n) ans++;  
        }
        ll num2;
        ans += max(0ll,x-l);
        if(x%2 == 0ll)ans = max(0ll,x-l);
        if(ans == 0ll){
            printf("Case %d: 0/1\n",Kase++);
            continue;
        }
        num2 = n-l+1;
        ll k = gcd(ans,num2);
        printf("Case %d: %lld/%lld\n",Kase++,ans/k,num2/k);
    }
    return 0;
}
### Gym-Gazebo Library for Robotics Simulation and Reinforcement Learning The **gym-gazebo** library is designed as a comprehensive toolset for roboticists, integrating simulation environments, middleware systems like ROS or ROS 2, and advanced machine learning paradigms such as reinforcement learning into one cohesive framework[^1]. This combination allows researchers and developers to design, test, and refine behavioral algorithms for robots within simulated conditions before deploying them onto real-world hardware. #### Key Features of gym-gazebo - It leverages the power of Gazebo—a widely-used physics simulator—to provide realistic simulations of robot dynamics. - The integration with ROS/ROS 2 enables seamless communication between different components involved in both simulation and physical deployment scenarios. - By incorporating reinforcement learning methodologies, it facilitates training models through trial-and-error processes while optimizing performance metrics over time. An updated version called **Gym-Ignition**, introduced later by some contributors working along similar lines but using Ignition instead of classic GAZEBOSimulations offers reproducible experiments which are crucial when comparing results across studies involving deep reinforcement learning applications specifically tailored towards autonomous vehicles among other domains mentioned earlier under references four & five respectively.[^4] Here’s how you can install `gym-gazebo` via pip command typically used inside Python virtual environments: ```bash pip install gym-gazebo ``` For more customized installations depending upon specific versions required alongside compatible dependencies including particular releases associated either directly from source repositories hosted generally at GitHub pages maintained actively throughout recent years until now; refer official documentation links provided usually after each release announcement posts found easily searching terms related above citations given previously too!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值