题意:

你有s个士兵,并打算把他们排成一个r行c列,但有两个"洞"的矩形方队,以迷惑敌人(从远处看,敌人可能误以为一共有r*c个士兵)。洞是两个大小相同的正方形,为了隐蔽性更强,方队边界(即第一行,最后一行,第一列,最后一列)的所有士兵都得在场,且每个洞的四个方向的士兵“士兵”厚度总是相同。输入士兵的实际个数S,计算缺失士兵数的所有可能值

解析:

设正方形边长为x  厚度为y

画一下图体会一下  6*y*y + 7*x*y = s

即 y*(6*y+7*x) = s

然后枚举y求x即可

注意y要从1开始枚举。。。

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 100000007
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff; int main()
{
LL s;
while(cin>> s && s)
{
int ok = ;
for(LL i=; i<=sqrt(s/ + 0.5); i++)
{
if(s % i == )
{
LL ans = s / i - *i;
if(ans <= ) continue;
if(ans % ) continue;
ans = ans/ % MOD;
ok = ;
printf("Possible Missing Soldiers = %lld\n",ans % MOD * ans % MOD * % MOD);
}
}
if(ok) cout<< "No Solution Possible" <<endl;
cout<<endl; }
return ;
}

Just Another Problem UVA - 11490(枚举)的更多相关文章

  1. UVA 11490 - Just Another Problem(数论)

    11490 - Just Another Problem option=com_onlinejudge&Itemid=8&page=show_problem&category= ...

  2. UVALive 7457 Discrete Logarithm Problem (暴力枚举)

    Discrete Logarithm Problem 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/D Description ...

  3. HDU 3699 A hard Aoshu Problem(暴力枚举)(2010 Asia Fuzhou Regional Contest)

    Description Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. N ...

  4. The 3n + 1 problem UVA - 100

    3n+1问题 PC/UVa IDs: 110101/100 Popularity: A Success rate: low Level: 1 测试地址: https://vjudge.net/prob ...

  5. UVa 12169 (枚举+扩展欧几里得) Disgruntled Judge

    题意: 给出四个数T, a, b, x1,按公式生成序列 xi = (a*xi-1 + b) % 10001 (2 ≤ i ≤ 2T) 给出T和奇数项xi,输出偶数项xi 分析: 最简单的办法就是直接 ...

  6. UVa 140 (枚举排列) Bandwidth

    题意较复杂,请参见原题=_=|| 没什么好说的,直接枚举每个排列就好了,然后记录最小带宽,以及对应的最佳排列. STL里的next_permutation函数真是好用. 比较蛋疼的就是题目的输入了.. ...

  7. UVa 1151 (枚举 + MST) Buy or Build

    题意: 平面上有n个点,现在要把它们全部连通起来.现在有q个套餐,如果购买了第i个套餐,则这个套餐中的点全部连通起来.也可以自己单独地建一条边,费用为两点欧几里得距离的平方.求使所有点连通的最小费用. ...

  8. 暴力求解——素环数 Prime Ring Problem ,UVa 524

    Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbers i ...

  9. Even Parity UVA - 11464 (枚举)

    从来没有觉得枚举有多费脑子的.但是这道题还是很香的. 思路:就是非常简单的枚举啦.   从一般的枚举开始考虑.一般的做法就是在所有的格子中有两种状态1, 0. 而一共有225个格子,所有一共要枚举的情 ...

随机推荐

  1. Makefile详解

    原文链接:https://blog.csdn.net/qq_38646470/article/details/79917494 专栏链接:https://blog.csdn.net/column/de ...

  2. cnblogs客户端配置说明

    1. 下载地址 http://openlivewriter.org/ 2.安装 安装时设置好blog地址和账户.密码: 到这里基本上就算安装完成了.如果之前的自动配置没有成功,会出现一个界面让你配置b ...

  3. opengl矩阵向量

    如何创建一个物体.着色.加入纹理,给它们一些细节的表现,但因为它们都还是静态的物体,仍是不够有趣.我们可以尝试着在每一帧改变物体的顶点并且重配置缓冲区从而使它们移动,但这太繁琐了,而且会消耗很多的处理 ...

  4. [egret]白鹭引擎打包安卓包体积太大减小

    萌新第一次用egret打安卓包,发现裸包22M+,吃惊到吃手手. 上网搜查无果. 可能原因是egret优化过一波打包,变得更便利了,网上对新版本打包比较少讨论. 解决方法: egret-android ...

  5. JavaScript学习笔记(八)—— 补

    第九章 最后的补充 一.Jquery简单阐述 JQuery是一个JavaScript库,旨在减少和简化处理DOM和添加视觉效果的JavaScript代码:使用时必须得添加库路径:学习路径:http:/ ...

  6. 从零系列--node爬虫利用进程池写数据

    1.主进程 const http = require('http'); const fs = require('fs'); const cheerio = require('cheerio'); co ...

  7. Python-RabbitMQ(持久化)

    生产者: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import pika   connection = pika.BlockingConnection(pi ...

  8. 高可用Kubernetes集群-16. ansible快速部署

    说明 本文档指导采用二进制包的方式快速部署高可用kubernetes集群. 脚本托管:k8s-ansible(持续更新) 参考:高可用kubernetes集群 组件版本 组件 版本 备注 centos ...

  9. 从零开始的Python学习Episode 17——序列化

    序列化 我们把对象(变量)从内存中变成可存储或传输的过程称之为序列化,在Python中叫pickling,在其他语 言中也被称之为serialization,marshalling,flattenin ...

  10. python 拾遗

    三引号 可以当做多行字符串使用.在类或者方法中用的时候,可以当做docstrings来使用.具体的规则为: 该文档字符串所约定的是一串多行字符串,其中第一行以某一大写字母开始,以句号结束.第二行为空行 ...