zoukankan      html  css  js  c++  java
  • Coin

    Bob has a not even coin, every time he tosses the coin, the probability that the coin's front face up is qp(qp≤12)frac{q}{p}(frac{q}{p} le frac{1}{2})pq​​(pq​​21​​).

    The question is, when Bob tosses the coin kkk times, what's the probability that the frequency of the coin facing up is even number.

    If the answer is XYfrac{X}{Y}YX​​, because the answer could be extremely large, you only need to print (X∗Y−1)mod(109+7)(X * Y^{-1}) mod (10^9+7)(XY1​​)mod(109​​+7).

    Input Format

    First line an integer TTT, indicates the number of test cases (T≤100T le 100T100).

    Then Each line has 3 integer p,q,k(1≤p,q,k≤107).7​​) indicates the i-th test case.

    Output Format

    For each test case, print an integer in a single line indicates the answer.

    样例输入

    2
    2 1 1
    3 1 2

    样例输出

    500000004
    555555560
    
    
    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <vector>
    #include <queue>
    #include <stack>
    #include <cstdlib>
    #include <iomanip>
    #include <cmath>
    #include <cassert>
    #include <ctime>
    #include <map>
    #include <set>
    using namespace std;
    #define lowbit(x) (x&(-x))
    #define max(x,y) (x>=y?x:y)
    #define min(x,y) (x<=y?x:y)
    #define MAX 100000000000000000
    #define MOD 1000000007
    #define pi acos(-1.0)
    #define ei exp(1)
    #define PI 3.141592653589793238462
    #define ios() ios::sync_with_stdio(true)
    #define INF 1044266558
    #define mem(a) (memset(a,0,sizeof(a)))
    typedef long long ll;
    ll p,q,k,n;
    ll quick_mod(ll x,ll y)
    {
        ll ans=1;
        while(y)
        {
            if(y&1) ans=ans*x%MOD;
            y>>=1;
            x=x*x%MOD;
        }
        return ans;
    }
    int main()
    {
        scanf("%lld",&n);
        while(n--)
        {
            scanf("%lld%lld%lld",&p,&q,&k);
            ll ans=quick_mod(p-2*q,k);
            ll pos=quick_mod(p,k);
            pos=quick_mod(pos,MOD-2);
            printf("%lld
    ",((1+ans*pos%MOD)%MOD)*quick_mod(2,MOD-2)%MOD);
        }
        return 0;
    }


    1pk((pq)+q)k+((pq)q)k2
  • 相关阅读:
    kitkat-s5p4418drone 记录
    Android USER 版本与ENG 版本的差异
    Android中的Apk的加固(加壳)原理解析和实现(转)
    Android悬浮窗实现 使用WindowManager
    Android系统的开机画面显示过程分析
    【PMP】变更流程图与说明
    【PMP】十五至尊图
    【Excle】一个比VLOOKUP牛的函数LOOKUP
    【DB2】慎用nickname,可能会引起效率较低
    【读书】人生向前-读书笔记
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7535017.html
Copyright © 2011-2022 走看看