UVA 11490 Just Another Problem
来源:互联网 发布:java acl权限控制 编辑:程序博客网 时间:2024/05/02 04:49
题意:S个士兵排成r行c列,其中队列中间有两个方队是空出来的,并且这两个方队大小相等,而且方队到四个方向外面的厚度都相同,求所有空出来的方队的情况。
思路:在纸上画一画就可以发现S可以写成这样的形式S=6*i*i+7*i*j。这样枚举i就行了。
代码:
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<map>#include<queue>#include<stack>#include<cmath>#include<vector>#define inf 0x3f3f3f3f#define Inf 0x3FFFFFFFFFFFFFFFLL#define eps 1e-9#define pi acos(-1.0)using namespace std;typedef long long ll;const int mod=100000007;int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); ll S; while(~scanf("%lld",&S)) { if(S==0) break; int cnt=0; ll i=1,tmp,tmp2,ans; while(true) { tmp=i*i*6; if(tmp>=S) break; tmp2=(S-tmp)/7; if((S-tmp)%7==0&&tmp2%i==0) { ans=tmp2/i; cnt++; ans%=mod; ans=ans*ans%mod; ans=ans*2%mod; printf("Possible Missing Soldiers = %lld\n",ans); } i++; } if(!cnt) printf("No Solution Possible\n"); printf("\n"); } return 0;}
0 0
- uva 11490 - Just Another Problem
- UVA 11490 Just Another Problem
- UVA 11490 - Just Another Problem(数论)
- uva 11490 - Just Another Problem(数学)
- uva 11490 ——Just Another Problem
- UVA - 11490 Just Another Problem (因数分解)
- Just Another Disney Problem
- 【ZOJ 3642】 Just Another Information Sharing Problem
- zoj 3642 Just Another Information Sharing Problem
- zoj 3642 Just Another Information Sharing Problem
- ZOJ 3642 Just Another Information Sharing Problem
- hdu 3259 Just Another String Matching Problem
- UVA 10516 Another Counting Problem
- HOJ 13108 Just Another Knapsack Problem (AC自动机+dp)
- Gym 100685 J Just Another Disney Problem 趣题,稳定排序
- ZOJ 3642Just Another Information Sharing Problem (最大流)
- Gym 100685J Just Another Disney Problem(交互/排序)
- uva 10516 - Another Counting Problem(dp)
- CString 字符分割 函数
- JAVA多线程和并发基础面试问答
- 找出一组数据中不同的数据
- json格式
- 访问修饰符 public、protected、internal 或 private (图)
- UVA 11490 Just Another Problem
- 百度地图与Android横竖屏切换的问题
- 黑马程序员-------线程(中)
- U-boot分析与移植(2)----U-boot stage1分析
- snmp-snmptranslate and loading mibs
- 一个算法作业--最大公约数
- string,stringbuffer,stringbuilder区别
- 基于ARM11的嵌入式linux系统移植与实现--(笔记一)
- 发送大量尽快恢复开始大力开发和临时卡的话富士达