uva 11971 Polygon 连续概率

  1. 都随机的点要通过假设先定下来,要考虑到假设时这种情况发生的种类数。
  2. 找到题意要求满足多边形的核心条件。

题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=229&page=show_problem&problem=3122

题解:把这段木条想象成一个圆,不能构成一个多边形的条件是有一条边大于等于这个木条的一半,而我们假设一个一个点随机选取,那么假设第i个点开始半周内不能有点,那么其它k个点都要在另一半,即1/2^k,而一共有k+1个点可供选择,所以最后结论就是1-(k+1)/2^k

#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<vector>
#include<fstream>
#include<list>
using namespace std;

#define ms(s) memset(s,0,sizeof(s))
typedef unsigned long long ULL;
typedef long long LL;

const int INF = 0x3fffffff;

LL gcd(LL a, LL b){
  return (b==0) ? a : gcd(b,a%b);
}

int main(){
//    freopen("F:\\input.txt","r",stdin);
//    freopen("F:\\output.txt","w",stdout);
//    ios::sync_with_stdio(false);

    int t;
    LL n,k;
    scanf("%d",&t);
    LL a,b;
    LL gcdd;
    for(int cas = 1; cas <= t; ++cas){
        scanf("%lld%lld",&n,&k);
        a = pow(2,k);
        b = a;
        a = a-k-1;
        gcdd = gcd(a,b);
        a /= gcdd;
        b /= gcdd;
        printf("Case #%d: %lld/%lld\n",cas,a,b);
    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值