Esempio n. 1
0
// code stolen from
// http://bocoup.com/processing-js/docs/index.php?page=Gaussian%20Blur
std::vector<float> makeBlurWeights(int blurDiameter)
{

    int gaussWidth = (blurDiameter * 2) + 1;

    // compute the blurDiameter'th row of pascal's triangle
    std::vector<float> previous(gaussWidth), pascals(gaussWidth);
    float rowSum = 0.;

    previous[0] = 1.;
    previous[1] = 1.;

    for (int r = 2; r <= gaussWidth; ++r) {
        rowSum = 0.;

        for (int c = 0; c < r; ++c) {
            pascals[c] = (c == 0) || (c == r - 1) ?
                    1. : previous[c] + previous[c - 1];
            rowSum += pascals[c];
        }

        previous = pascals;
    }

    // normalize the weights
    for (int i = 0; i < gaussWidth; ++i)
        pascals[i] /= rowSum;

    return pascals;
}
Esempio n. 2
0
int main()
{
    int t,n,i,ans;
    t=scan();
    pascals();
    while(t--)
    {
        n=scan();
        ans=0;
        for(i=0;i<n;i++)
        {
            a[i]=scan();
        }
        if(n==1) printf("1\n");
        else
        {
            for(i=n/2+1;i<=n;i++)
            {
                ans=(ans+arr[n][i])%MOD;
            }
            printf("%d\n",ans);
        }

    }
    return 0;
}
Esempio n. 3
0
int main()
{

    int n,r;
    scanf("%d %d",&n,&r);
    pascals(n);
    if(n<r) printf("-1");
    else printf("%d",arr[n-1][r-1]);
    return 0;
}
Esempio n. 4
0
int main()
{
    ll t,n;
    int i;
    pascals();
    t=scan();
    while(t--)
    {
        n=scan();
        for(i=1;i<=64;i++)
        {
            if(arr[i][i/2]>=n)
            {
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}