![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
nyoj
一只会旅行的猫
这个作者很懒,什么都没留下…
展开
-
nyoj 71 独木舟上的旅行
http://acm.nyist.net/JudgeOnline/problem.php?pid=711)法一分析:该算法是先将载重排序,然后从较重的货物开始,从0寻找符合条件的货物,直到i>=j #include#include#include using namespace std;int main(){ int i,j,n,w,t,T,count; int b[3原创 2013-06-15 20:37:07 · 482 阅读 · 0 评论 -
nyoj 927 The partial sum problem
#include #include #include #include using namespace std;const int NM=30;int a[NM],sum,n;bool flag;bool comp(int x,int y){ return x>y;}void DFS(int res,int i){ if(flag || i>n) return;原创 2014-05-16 21:35:02 · 541 阅读 · 0 评论 -
nyoj 43 24 Point game
http://acm.nyist.net/JudgeOnline/problem.php?pid=43分析:#include #include #include #include using namespace std;const int NM=15;const double eps=1e-6;bool vis[NM],flag;double a[NM];int n,m原创 2014-05-14 19:10:46 · 432 阅读 · 0 评论 -
【DFS】nyoj 325 zb的生日
#include#include#include#include#includeusing namespace std;int sum,a[25],flag,T;void DFS(int x,int SUM){if(x==T)return;int temp=(int)fabs(sum-2*SUM);if(tempflag=temp原创 2013-06-08 23:52:56 · 627 阅读 · 0 评论 -
【DFS】nyoj 20 吝啬的国度
http://acm.nyist.net/JudgeOnline/problem.php?pid=20分析:从某点逆向开始搜寻,生成树#include#include#include#include#includeusing namespace std;const int N=100005;vectorve[N];int city[N];void DFS(int原创 2013-06-12 00:09:28 · 849 阅读 · 0 评论 -
【DFS】nyoj 488 素数环
http://acm.nyist.net/JudgeOnline/problem.php?pid=488#include#include#includeusing namespace std;int a[50],save[25],vis[25];int n,flag;void DFS(int x,int num){ int i; if(x==n&&!a[1+n原创 2013-05-29 21:27:12 · 955 阅读 · 0 评论 -
【树状数组】nyoj 116 123 士兵杀敌
nyoj 116 分析:单点插入,求区间和#include#include#include#includeusing namespace std;const int NUM=1000010;int a[NUM],N;int lowbit(int t) //2^k{ return t&(t^(t-1));}int sum(int t){ int原创 2014-01-29 19:36:07 · 806 阅读 · 0 评论 -
nyoj 127&&nyoj 170
http://acm.nyist.net/JudgeOnline/problem.php?pid=127分析:cayley定理:即过n个有标志顶点的树的数目等于n^(n-2)。百科#include #include using namespace std;const int NM=10003;int main(){ int j,T,ans,num; sc原创 2013-09-27 21:02:38 · 559 阅读 · 0 评论 -
nyoj 21 三个水杯
http://acm.nyist.net/JudgeOnline/problem.php?pid=21分析:可以倒水的共有6种情况,即:1-2,1-3,2-3,3-2,3-2,2-1(需要判断倒水杯子是否有水,被倒的杯子是否满了)然后bfs,啊~~#include#include#include #include using namespace std;int V1,V2,原创 2013-06-20 23:17:54 · 638 阅读 · 0 评论 -
nyoj 92 图像有用区域
http://acm.nyist.net/JudgeOnline/problem.php?pid=92分析:主要找出在线圈内的像素和先圈外的像素有神马区别,我的想法是线圈内的东东所在的位置上下左右都存在0,然后四个方向遍历,确定它是否在圈内#include #include #include using namespace std;const int N=1445;int原创 2013-06-19 21:03:09 · 697 阅读 · 0 评论 -
nyoj 6 喷水装置(一)
分析:想要完整覆盖,需要两个圆相交,得到有效的距离为下图中红线段,即:x=sqrt(r*r-1*1)#include#include#include#include #include using namespace std;const int NUM=605;double a[NUM];bool comp(double A,double B){ if(A>B原创 2013-06-16 19:25:20 · 788 阅读 · 0 评论 -
田忌赛马
分析:反正就是让1)A的好马>B好马,win2)A的慢马>B的慢马,lost3)1、2条件都不满足时,用A的慢马->B的好马,平局不管,否则lost#include#include#includeusing namespace std;const int N=1005;int a[N],b[N];bool comp(int A,int B){ if(A>B) ret原创 2013-06-15 23:55:29 · 635 阅读 · 0 评论 -
【DFS】nyoj 82 迷宫寻宝(一)
http://acm.nyist.net/JudgeOnline/problem.php?pid=82 #include#include#include#include#includeusing namespace std;char str[25][25];int b[5],c[5],doorx[5],doory[5],vis[25][25],s原创 2013-06-10 23:32:53 · 678 阅读 · 0 评论