/** 大意:给定一个色子,有n个面,每一个面上有一个数字,在其中的m个面上有特殊的颜色,当掷出的色子出现这m个颜色之一时,可以再掷一次..求其最后的期望 思路:假设 期望为ans 4 ans = 1/n*(a[b[1]]+ans)+1/n*(a[b[2]]+ans)+....+1/n*(a[b[m]]+ans) +...+1/n*(a[k]).... 5 ans = m/n*ans+1/n*(a[1]+a[2]+a[3]+...a[n]) 6 ans = m/n*ans+sum/n 7 ans…
题意:求一个无向图的,去掉两个不同的点后最多有几个连通分量. 思路:枚举每个点,假设去掉该点,然后对图求割点后连通分量数,更新最大的即可.算法相对简单,但是注意几个细节: 1:原图可能不连通. 2:有的连通分量只有一个点,当舍去该点时候,连通分量-1: 复习求割点的好题! #include<iostream> #include<cstdio> #include<vector> using namespace std; int n,m; vector<vector&…
/** 大意: 给定区间(a,b), 将其转化为二进制 计算从a+(a+1)+(a+2)....+(a+b-1),一共有多少次进位 思路: 将(a,b)区间内的数,转化为二进制后,看其每一位一共有多少个1 可知最低位循环为2,第二位循环为4 ---〉 所以每一位的1的个数为 : 假设为第三位 (n-n%8)/8*8/2===>(n-n%8)/2 ------> 如果n%8 大于8/2 那么应该再加上 n%8-8/2 **/ #include <iostream> #include…
/** 大意:给定一组x[],y[],z[] 确定有没有两个不同的x[i], x[j] 看是否存在一个ID使得 y[i]<=ID%x[i]<=z[i] y[j]<=ID%x[j]<=z[j] 设ID%x[i] = a ID%x[j] = b ===〉ID+x[i]*x=a, ID+x[j]*y = b; 两式相减得 x[j]*y - x[i]*x = b-a; 若是有解 就是(b-a)%gcd(x[i],x[j]) == 0 就是看b-a的范围内是否有数是 gcd(x[i],x[j…
题目链接:http://icpc.njust.edu.cn/Contest/194/Problem/B B - TWO NODES 时间限制: 10000 MS 内存限制: 65535 KB 问题描述 Suppose that G is an undirected graph, and the value of  stab is defined as follows: Among the expression, G-i,-j  is the remainder after removing no…
Divide Groups Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 423    Accepted Submission(s): 161 Problem Description   This year is the 60th anniversary of NJUST, and to make the celebration mor…
Count The Pairs Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 277    Accepted Submission(s): 150 Problem Description   With the 60th anniversary celebration of Nanjing University of Science…
Walk Through Squares Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 200    Accepted Submission(s): 57 Problem Description   On the beaming day of 60th anniversary of NJUST, as a military colleg…
ssworld VS DDD Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1487    Accepted Submission(s): 304 Problem Description One day, sssworld and DDD play games together, but there are some special…
题意:求用N(1<=N<=100)个骰子掷出M(1<=M<=600)的概率 分析:直接求概率可能出现6^100次方,会爆精度.可以用一个数组dp[i][j]记录用i个骰子掷出j的概率.i为0时无论j是多少,概率都是0.i为1时,j从1-6的概率都是1/6.其余可以递推得到 dp[i][j]  = 0 (j<i || j>6*i),sigma(dp[i-1][max(0,j-k)])  (1<=k<=6) #include<stdio.h> #in…