uva11490

注意到S<=1e12,当S取到最大值时候,每个方块外部的士兵厚度仅有68041,可以考虑枚举士兵厚度求解。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const long long mod = 1e8 + 7;
LL S;
int main()
{
    while (scanf("%lld", &S) == 1 && S) {
        int ok = 0;
        for (LL r = 1; 6 * r*r < S; r++) {
            if ((S - 6 * r*r) % (7 * r))continue;
            LL x = (S - 6*r*r) / (7*r);
            if (6 * r*r + 7 * x*r == S) {
                ok = 1;
                x %= mod;
                LL res = (x * x * 2) % mod;
                printf("Possible Missing Soldiers = %lld\n", res);
            }
        }
        if (!ok) {
            printf("No Solution Possible\n\n");
            continue;
        }
        else printf("\n");
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值