上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 38 下一页
摘要: 题解:记答案为ans,已知,对一个确定的顺序,计算所用的时间长短就是从最后向前计算,计算方法如下:ans+=(p[i].b+ans*p[i].a)/(v-p[i].a)那么,应该如何调整顺序使得答案最小呢?我们将这个式子拆开得到ans+=p[i].b/(v-p[i].a)+(ans*p[i].a)/... 阅读全文
posted @ 2014-08-18 07:46 forever97 阅读(375) 评论(0) 推荐(0) 编辑
摘要: 题解:因为模比较小,所以一定会产生循环节,所有先计算循环节,然后直接求解。#include int main(){ int a,b,n,f[50]; f[1]=f[2]=1; while(scanf("%d%d%d",&a,&b,&n),a|b|n){ int t1,t2,... 阅读全文
posted @ 2014-08-14 10:06 forever97 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 题解:线段树单点更新区间求极值。#include #include using namespace std;int a,b,q[200005],t[1200000];void build(int l,int r,int x){ int mid=(l+r)>>1; if(l==r){t[x... 阅读全文
posted @ 2014-08-14 09:48 forever97 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 题解:首先,按照题目要求生成数列,需要注意的是数据超过了int的范围,所以要开long long,然后,就用逆序对的思想求单调数列的个数。#include #include using namespace std;const int mod=1000000007;typedef long long ... 阅读全文
posted @ 2014-08-13 18:52 forever97 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题解:首先是很基础的树状数组求逆序对,然后对于每一个第一个数往后移动,对于逆序数的贡献是n-a[i]-1-a[i]。枚举然后求最小值即可。#include #include #include using namespace std;int n,c[5001],x,a[5001];int add(in... 阅读全文
posted @ 2014-08-13 14:19 forever97 阅读(122) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;int p1,p2,a[6],T;int main(){ scanf("%d",&T); while(T--){ for(int i=0;ip2)puts("Grandpa Shawn is the... 阅读全文
posted @ 2014-08-11 10:32 forever97 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 题解:用a[i]表#include #include using namespace std;struct data{int len,a[2002];}a[35],c,p,t;int n,d;data mul(data a,data b){ memset(c.a,0,sizeof c.a); ... 阅读全文
posted @ 2014-07-21 10:41 forever97 阅读(363) 评论(0) 推荐(0) 编辑
摘要: 题解:如果确定了第一排前两个数,那么剩下的数是唯一确定的,所以只要分情况讨论即可。#include #include int n,a[10010],s[10010];int ans(int x){ memset(a,0,sizeof a); if(x==1)a[1]=1; if(x... 阅读全文
posted @ 2014-07-21 08:46 forever97 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 题解:同BZOJ 3211 花神游历各国,需要注意的是需要开long long,还有左右节点需要注意一下。#include #include #include #include using namespace std;typedef long long LL;LL a[100005],c[10000... 阅读全文
posted @ 2014-07-20 16:17 forever97 阅读(546) 评论(0) 推荐(0) 编辑
摘要: 题解:首先,单点修改求区间和可以用树状数组实现,因为开平方很耗时间,所以在这个方面可以优化,我们知道,开平方开几次之后数字就会等于1 ,所以,用数组记录下一个应该开的数,每次直接跳到下一个不是1的数字进行开平方,至于这个数组,可以用并查集维护。#include #include #include u... 阅读全文
posted @ 2014-07-20 16:14 forever97 阅读(1034) 评论(1) 推荐(2) 编辑
摘要: 题解:首先,这道题可以用位运算来表示每一行的状态,同八皇后的搜索方法,然后对于限制条件不相互攻击,则只需将新加入的一行左右移动与上一行相&,若是0则互不攻击,方案可行。对于每种方案,则用递推来统计,将前一排所有可以的情况全部加上即可。bit数组记录每个数字二进制位中1的个数,方便计算。if(chec... 阅读全文
posted @ 2014-07-20 14:53 forever97 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 题解:http://vfleaking.blog.163.com/blog/static/17480763420119685112649/#include #include using namespace std;struct data{int a[101],len;};data mul(data ... 阅读全文
posted @ 2014-07-20 09:22 forever97 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 题解:n为树的节点数,d[ ]为各节点的度数,m为无限制度数的节点数。则所以要求在n-2大小的数组中插入tot各序号,共有种插法;在tot各序号排列中,插第一个节点的方法有种插法;插第二个节点的方法有种插法; .........另外还有m各节点无度数限制,所以它们可任意排列在剩余的n-2-tot的空... 阅读全文
posted @ 2014-07-17 15:10 forever97 阅读(571) 评论(0) 推荐(0) 编辑
摘要: 题解:数据结构的基本操作,用STL可以完美实现,就是比较慢……#include #include #include #include #include const int MAXN=500005; const int INF=~0U>>1; using namespace std; ... 阅读全文
posted @ 2014-07-17 14:42 forever97 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 题解:正难则反,从总数中减去全部相邻不相同的数目就是答案,n*(n-1)^(m-1):第一个房间有n中染色方案,剩下m-1个房间均只有n-1种染色方案,用总数减就是答案。#include const int mod=100003; typedef long long LL; LL n,m; LL p... 阅读全文
posted @ 2014-07-17 10:44 forever97 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 题解:简单的NIM游戏,直接计算SG函数,至于找先手策略则按字典序异或掉,去除石子后再异或判断,若可行则直接输出。#include const int N=1005;int SG[N],b[N],hash[N],a[N],sum,tmp,i,j,n,m; void FSG(int s){ ... 阅读全文
posted @ 2014-07-17 09:57 forever97 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 题解:注意题目中规定取到最后一粒石子的人算输,所以是Anti-Nim游戏,胜负判断为:先手必胜: 1.所有堆的石子数都为1且游戏的SG值为0; 2.有些堆的石子数大于1且游戏的SG值不为0。#include int main(){ int t,n,s,x,tmp; scanf("%d... 阅读全文
posted @ 2014-07-17 09:23 forever97 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 题解:直接使用STL中的hash去重即可#include #include using namespace std;int ans[50010];int main(){ int T,n,tmp; scanf("%d",&T); while(T--){ int cnt=... 阅读全文
posted @ 2014-07-17 08:45 forever97 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 题解:简单博弈论#include int main(){ int n; while(scanf("%d",&n),n!=0) if (n&1) puts("Bob"); else puts("Alice"); return 0;} 阅读全文
posted @ 2014-07-17 08:42 forever97 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 题解:鉴于二进制的思想来划分#include int main(){ int n,d=0;scanf("%d",&n); while(1<<d<=n)d++; printf("%d\n",d);} 阅读全文
posted @ 2014-07-17 08:38 forever97 阅读(176) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 38 下一页