题意给出甲乙丙三人的能力值关系:甲的能力值确定是 2 位正整数;把甲的能力值的 2 个数字调换位置就是乙的能力值;甲乙两人能力差是丙的能力值的 X 倍;乙的能力值是丙的 Y 倍。输入为你的能力值,X,Y输出甲的能力值,以及甲乙丙三人和你的关系(‘ping’=,‘cong’>,‘gai’<)本题先根据X,Y值求出甲乙丙的能力值,因为甲是两位数,这里可以使用两个for循环分别作为十位和个位
转载
2023-06-28 00:25:10
65阅读
import sysn = int(raw_input())for i in range(1, n+1) : num = sys.stdin.readline() an = num.split() a = int(an[0]) b = int(an[1]) if(a%2...
转载
2013-03-15 19:45:00
113阅读
2评论
A Apples and Ideas "If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you ha
转载
2016-04-23 17:50:00
80阅读
ZOJ3321 //there is at most one edge between two nodes. 因为这句话的局限性,又要满足环,那么一定是每个点度为2,然后为n节点的一个环 //#include #include#include#includeusing namespace std...
转载
2017-02-11 13:12:00
312阅读
2评论
#include #include using namespace std;int res[8001]; int main(){ int i,j,k,T; int ans[8001]; while(cin>>T) { int Max = -1, Min = 8001; memset(ans,-1,sizeof(ans));//下标为区间,值为颜色 memset(res,0,sizeof(res));//下标为颜色,值为组数 for(i=1; i>a>>b>>c; if(aMax) ...
转载
2012-08-13 10:37:00
49阅读
2评论
You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or the film of the same name by Stanley Kubrick. In it a spaceship is sen
转载
2017-03-08 15:00:00
128阅读
2评论
赤裸的带禁区的排列数,不过,难点在于如何用程序来写这
转载
2014-10-01 11:31:00
46阅读
2评论
很简单的概率题了设dp[x]为能力值 为x时出去的期望 天数#include #include #include #include #include using namespace std;double dp[20005];int ci[125];double is=0.5*(1+sqrt(5));...
转载
2014-11-19 20:42:00
44阅读
2评论
这题,找找规律,可以发现一个斐波那契数列。按照斐波那契数列求和,知道,SUM=Fn+2-F1,于是,该长度为Fn+2的倍数。因为斐波那契数列不一定是从1开始的,而从2开始的每个数都是从1开始的倍数。于是,只需求出最大的Fn+2是长度的倍数即可。#include #include #include u...
转载
2014-10-06 10:24:00
64阅读
2评论
求不比M大的可以被集合任一个数整除的数的个数。(容斥原理)#include #include #include #include using namespace std;int set[15];int ans;int gcd(int a,int b){ if(b==0) return a; retu...
转载
2014-10-02 15:33:00
51阅读
2评论
这题是二分+2SAT.总结一下SAT题的特征。首先,可能会存在二选一的情况,然后会给出一些矛盾。据这些矛盾加边,再用SAT判定。这一道题好像不能直接用printf("%0.3lf"),因为这个是四舍五入的,这道题好像不能四舍五入,只好选减去0.0005再按这个格式输出了。 1 #include ...
转载
2014-07-20 10:29:00
62阅读
2评论
这题难在破环。对于不是环的情况,只需按照一般的树形DP来做,一步一步往根递推就可以了。对于环,则枚举其中一点的两种情况,取或不取,然后再递推,就可以了。当到达某结点的下一结点为环开始的点时,退出即可。 1 #include 2 #include 3 #include 4 #include 5...
转载
2014-07-17 14:02:00
30阅读
2评论
At 0 second, the LED light is initially off. After BaoBao presses the button 2 times, the LED light turns on and the value of the counter changes to 1
转载
2018-09-18 09:21:00
70阅读
2评论
In computability theory, the halting problem is the problem of determining, from a description of an arbitrary computer program, whether the program w
转载
2018-09-18 00:12:00
62阅读
2评论
回溯,dfs实现,注意要用long long, 9个100相乘最大数需要long long表示。 #include <iostream>#include <cstdio>
using namespace std;
long long a[20];
int n;
int k;
long long ans;
const long long inf = 10000000000
转载
2009-09-05 23:31:00
54阅读
2评论
最短路问题,要求出最短路的个数。输出一条得到JavaBean最多的最短路径 #include<stdio.h>#include<string.h>#define inf 0x3fffffffint n,m,map[510][510],dp[510],mark[510],dis[510],w[510],pre[510],link[510];int st,ed;void dijkstra(){ int i,j,k,min; memset(mark,0,sizeof(mark));//标记房间是否走过 memset(dp,0,sizeof(dp));//记录到达位置得到最多的
转载
2013-06-06 22:28:00
42阅读
2评论
缩点+dfs判环首先把所有的点缩成7类中的一个,对于AAAAAAA这种,缩成一个点就好,一个点可以和周围连起来就全都能连起来;对于ACACACACA这种,要缩成两个点,因为要是剩下的只有一个A和一个C,缩成一个点是不行的,但是实际上是可行的;对于ACGACGACG这种当然就是缩成三个点了。然后图中最多只有1+1+1+2+2+2+3=1
原创
2023-09-15 09:12:36
39阅读
首先,最优的方案里,我们是不会增加石头路的费用的,也不可能去降低烂泥路的费用,所以可以认为对石头路有d=c-l,对烂泥路有d=c+
原创
2023-09-15 09:17:51
50阅读
HanioTower的加强版记f[n][m]为n个disc,m个peg的Hanoi问题,则有dp公式f[n][m]=min{f[n-k][m-1]+2*f[k][m]}。即把上面的k个disc利用m个peg转移某个中间peg,再把下面的n-k个disc利用m-1个peg转移到目标peg,最后把上面的k个disc利用m个peg移到目标peg。dp过程记下使得f[n][m]最小的g[n][m]=k用于
转载
2013-04-05 20:49:00
28阅读