zoukankan      html  css  js  c++  java
  • UVA-11490 Just Another Problem

    题目大意:一个由p*q个点组成的pxq点阵(构成一个矩形)。从内层点中拿走两块正方形上的所有点,这两块正方形要边长相等,在位置上关于中线对称,并且还要使每一个正方形的上下左右剩余的点的层数相等。现在告已知拿走以后剩余的点的个数s,求可能拿走了多少个点。

    题目分析:当拿走了2n^2个点时,根据题设中的条件依据,剩余的点的个数为 s=7nk+6k^k  (其中,k为层数)。枚举k,可得n,问题解决。

    代码如下:

    # include<cstdio>
    using namespace std;
    # define LL long long
    const LL mod=100000007;
    int main()
    {
        LL s;
        while(~scanf("%lld",&s)&&s)
        {
            int yy=1;
            for(LL k=1;6*k*k<s;++k){
                LL u=s-6*k*k;
                if(u%(7*k)==0){
                    LL n=u/(7*k)%mod;
                    printf("Possible Missing Soldiers = %lld
    ",n*n*2%mod);
                    yy=0;
                }
            }
            if(yy)
                printf("No Solution Possible
    ");
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    1434. Buses in Vasyuki 夜
    SAP
    目标
    组合数
    KM算法模板
    网络流
    CodeForces 43E
    B. Unsorting Array codeforces 127
    Colorful Rainbows 127
    C. Anagram codeforces
  • 原文地址:https://www.cnblogs.com/20143605--pcx/p/4714629.html
Copyright © 2011-2022 走看看