HDU 5478 Can you find it 随机化 数学】的更多相关文章

Can you find it Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5478 Description Given a prime number C(1≤C≤2×105), and three integers k1, b1, k2 (1≤k1,k2,b1≤109). Please find all pairs (a, b) which satisfied the…
HDU 5478 Can you find it 题意略. 思路:先求出n = 1 时候满足条件的(a,b), 最多只有20W对,然后对每一对进行循环节判断即可 #include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque> #include <vector> #i…
HDU 5073 Galaxy (2014 Anshan D简单数学) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5073 Description Good news for us: to release the financial pressure, the government started selling galaxies and we can buy them from now on! The first one who bought…
题目大意: 给你  ak1⋅n+b1+ bk2⋅n−k2+1 = 0 (mod C)(n = 1, 2, 3, ...). 要求所有的n都满足上述的式子. 问这样的a,b 有多少对?   分析这个问题的时候需要补充一下余数的性质定理.   若a≡b (% p),则对于任意的c,都有(a + c) ≡ (b + c) (%p): 若a≡b (% p),则对于任意的c,都有(a * c) ≡ (b * c) (%p): 若a≡b (% p),c≡d (% p), 则 (a + c) ≡ (b + d…
Zhuge Liang's Mines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4739 Description In the ancient three kingdom period, Zhuge Liang was the most famous and smartest military leader. His enemy was Shima Yi, who…
夹角有多大II Problem Description 这次xhd面临的问题是这样的:在一个平面内有两个点,求两个点分别和原点的连线的夹角的大小.注:夹角的范围[0,180],两个点不会在圆心出现. Input 输入数据的第一行是一个数据T,表示有T组数据.每组数据有四个实数x1,y1,x2,y2分别表示两个点的坐标,这些实数的范围是[-10000,10000]. Output 对于每组输入数据,输出夹角的大小精确到小数点后两位. Sample Input 2 1 1 2 2 1 1 1 0 S…
题意: 中文. 思路: 不难发现数学规律是这样的,每次增加的划分区域的数量是每次增加的交点的数量再加一.然后就总结出了递推公式. #include<stdio.h> ]; int main() { ans[]=; ; ;i<=;i++) { ans[i]=ans[i-]+tmp*+; tmp+=; } int t; scanf("%d",&t); ;tt<=t;tt++) { int n; scanf("%d",&n); pr…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1284 Problem Description 在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法.请你编程序计算出共有多少种兑法. Input 每行只有一个正整数N,N小于32768. Output 对应每个输入,输出兑换方法数. Sample Input 2934 12553 Sample Output 718831 13137761 解题思路:这道题可以当做数学题来做.假设某种方案…
题目链接:pid=5063" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=5063 Problem Description You have an array consisting of n integers: a1=1,a2=2,a3=3,-,an=n. Then give you m operators, you should process all the operators in order…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6242 思路:当 n == 1 时 任取一点 p 作为圆心即可. n >= 2 && n < 5 时 此时有可能出现所有点共线,所以取任意俩点间中点作为圆的圆心. n >= 5 保证了有解.所以不可能有所有点共线的情况,随机取三个点在正解圆上的概率是 1/8,还是蛮大的.... 外学了下随机算法的写法....时间种子 time(0)要强制转成int,不然会WA,不造为啥....…
8进制转为10进制 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map> using namespace std; #define MOD 1000000007 const int INF=0x3f3f3f3f; ; typedef lon…
a1/sum #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map> using namespace std; #define MOD 1000000007 const int INF=0x3f3f3f3f; ; typedef long l…
Problem Description Given a prime number C(1≤C≤2×105), and three integers k1, b1, k2 (1≤k1,k2,b1≤109). Please find all pairs (a, b) which satisfied the equation ak1⋅n+b1+ bk2⋅n−k2+1 = 0 (mod C)(n = 1, 2, 3, ...).   Input There are multiple test cases…
题意:给你一个带权的无向图,然后q(q≤5000)次询问,问有多少对城市(城市对(u,v)与(v,u)算不同的城市对,而且u≠v)之间的边的长度不超过d(如果城市u到城市v途经城市w, 那么需要城市u到城市w的长度e1≤d,同时城市w到城市v的长度e2≤d). 析:一开始的时候,题意都读错了,怎么看都不对,原来是只要最大的d小于等于x就可以,过了好几天才知道是这样..... 这个题是并查集的应用,先从d小的开始遍历,然后去判断有几个连通块,在连通块中计数,用一个数组即可,运用排列组合的知识可以知…
Problem Description Coach Pang and Uncle Yang both love numbers. Every morning they play a game with number together. In each game the following will be done: . Coach Pang randomly choose a integer x in [a, b] with equal probability. . Uncle Yang ran…
Problem Description There is a big stone with smooth surface in Tina Town. When people go towards it, the stone surface will be lighted and show its usage. This stone was a legacy and also the center of Tina Town’s calculation and control system. als…
Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to record the…
1060 - Leftmost Digit 1601 - Rightmost Digit 1060题意很简单,求n的n次方的值的最高位数,我们首先设一个数为a,则可以建立一个等式为n^n = a * 10^x;其中x也是未知的: 两边取log10有:lg(n^n) = lg(a * 10^x); 即:n * lg(n)  - x = lg(a); 现在就剩x一个变量了,我们知道x是值n^n的位数-1,a向下取整就是我们要求的数: 所以 按着上面的推导式翻译成代码就可以了(注意:数值的范围和之间的…
⋅n+b1⋅n−k2+1 = 0 (mod C)(n = 1, 2, 3, ...)  (1<=a, b <C) 1.  当n = 1时, a^(k1+b1) + b = 0 ( mod C)   => a^(2 * k1+b1) + b*a^(k1) = 0 ( mod C)     ① 当n = 2时, a^(2 * k1 + b1) + b^(k2 + 1) = 0 (mod C)       ② 所以  ① ,②结合  可以推出 b^(k2) = a^(k1) 所以求出 a ,b…
多校1 1004 HDU-6036 Division Game 题意 有k堆石头(0~k-1),每堆n个.\(n=\prod_{i=0}^{m}p_i^{e_i}\).\(0\le m,k \le 10,2\le p\le 10^9,1\le e_i,\sum_{i=0}^me_i\le 10^5,\) 现在第i次操作可以选择第i%k堆石头,移走该堆部分石头,使得剩下的数是原来的约数.当某堆不能操作时游戏结束.求结束于每一堆的方案数.答案取模\(985661441\). 题解 参考官方题解. 对…
BUPT2017 wintertraining(15) #8C 题意 求第n(n<2^32)个非完全平方数m,以及\(\sum_{i=1}^m{\lfloor\sqrt i\rfloor}\) 题解 设1~m中有x个完全平方数(\(1^2,2^2,3^2,...,x^2\)). 那么有 \[ \begin{cases} n+x=m\\ x^2 < m\\ (x+1)^2 \ge m \end{cases} \] 等价于求满足\(m-\sqrt m < n\)的m的最大值. 于是可以二分.…
The sum problem Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 31453    Accepted Submission(s): 9414 Problem Description Given a sequence 1,2,3,......N, your job is to calculate all the possib…
题目链接 Problem DescriptionWisKey的眼镜有500多度,所以眼神不大好,而且他有个习惯,就是走路喜欢看着地(不是为了拣钱哦^_^),所以大家下次碰见他的时候最好主动打下招呼,呵呵. 但是Rabbit总是喜欢扮神秘,一天WisKey去食堂排队等着买饭,突然收到一道短消息,是Rabbit发的,"呵呵,又看见你了,你没看到我吧".WisKey马上拉长脖子扫描食堂,可是就是看不到,再发短信问Rabbit在哪,Rabbit回信曰"我已经在寝室了".Wi…
题目链接 Problem Description Everyone know the story that how Newton discovered the Universal Gravitation. One day, Newton walked  leisurely, suddenly, an apple hit his head. Then Newton discovered the Universal Gravitation.From then on,people have sovle…
题目链接 Problem Description " 改革春风吹满地, 不会AC没关系; 实在不行回老家, 还有一亩三分地. 谢谢!(乐队奏乐)" 话说部分学生心态极好,每天就知道游戏,这次考试如此简单的题目,也是云里雾里,而且,还竟然来这么几句打油诗. 好呀,老师的责任就是帮你解决问题,既然想种田,那就分你一块. 这块田位于浙江省温州市苍南县灵溪镇林家铺子村,多边形形状的一块地,原本是linle 的,现在就准备送给你了.不过,任何事情都没有那么简单,你必须首先告诉我这块地到底有多少面…
题目链接 Problem Description     There are two circles in the plane (shown in the below picture), there is a common area between the two circles. The problem is easy that you just tell me the common area.   Input There are many cases. In each case, there…
6305.RMQ Similar Sequence 这个题的意思就是对于A,B两个序列,任意的l,r,如果RMQ(A,l,r)=RMQ(B,l,r),B序列里的数为[0,1]的实数,B的重量为B的所有元素的和,否则为0.问你B的期望重量是多少. dls讲题说是笛卡尔树,笛卡尔树是一种特定的二叉树数据结构,具体的看这篇博客吧:[pushing my way]笛卡尔树 这个题就是笛卡尔树同构的问题,假设A的笛卡尔树的子树大小为sz[u],那么序列B与A同构的概率为,因为B中的数满足均匀分布(因为B中…
Can you find it Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 450    Accepted Submission(s): 208 Problem Description Given a prime number C(1≤C≤2×105), and three integers k1, b1, k2 (1≤k1,k2,b…
题意:... 析:我们可以知道,a1+a2=b1,那么我们可以枚举a1,那么a2就有了,并且a1+a3=b2,所以a3就有了,我们再从把里面的剩下的数两两相加,并从b数组中去掉, 那么剩下的最小的就是a4,然后依次可以求出a5,a6....由于a最大才是5000,并且保证有唯一解,那么找到一个就直接退出. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #incl…
题意: 从给出的颜料中选出天数个,第一天选一个,第二天选二个... 例如:第二天从4个中选出两个,把这两个进行异或运算(xor)计入结果 对于每一天输出所有异或的和 $\sum_{i=1}^nC_{n}^{i}$ 思路: 0⊕0=0,1⊕0=1,0⊕1=1,1⊕1=0(同为0,异为1) 例如样例 4 1 2 10 1 这4个数的二进制表示分别为: 0 0 0 1 0 0 1 0 1 0 1 0 0 0 0 1 第一天: 分别选出 1, 2, 10 ,1 = 14 第二天: 从4个中选出2个进行异…