ACM_思维与数学
zz你的名字
不奢望过多,只希望未来的自己没有过多的遗憾。
展开
-
scu Easy Problem VI SCU
Time Limit: 1000 MS Memory Limit: 131072 K DescriptionIn this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.For exampl原创 2017-03-18 15:45:04 · 481 阅读 · 0 评论 -
zzuli 1728: 社交网络(组合数打表)
zzuli 1728: 社交网络 题意:中文题,不多说。 解法:先组合数打表,打一个c[30][30]的表记录一下。假设一个点是女的,那么与她相连的点为kk个,那么kk中选出k~kk个为男的那么就是C(kk,k~kk),分母为2的kk次方,又因为多枚举了一个男女的情况,所以除2.#include<stdio.h>#include<string.h>#incl...原创 2018-04-21 21:01:02 · 205 阅读 · 0 评论 -
hdu4135(容斥原理
题目hdu4135题解容斥原理简单解释: 解释完毕。 那么我们如何求这道题呢? 求[1,m]内与n互质的数的个数=m-[1,m]内与n不互质的个数(听起来就像废话,我一开始也是这么认为的,但是容斥原理就是求[1,m]内与n不互质的个数的)。 那么怎么求?首先举个例子 n除以奇数个数相乘的时候是加,n除以偶数个数相乘的时候是减。 就是这样,最后不懂就看代码吧!原创 2018-01-30 14:50:15 · 298 阅读 · 0 评论 -
poj2356(抽屉原理
题目poj2356思路抽屉原理 现在我们想办法把n变成n个物品,n-1变成n-1个抽屉。 sum[i]表示(a[1]+…+a[i])%n取模,那么sum[i]中表示的数只能是0到n-1,如果是0就满足题意,如果不是0,那么根据抽屉原理sum[i]为n个数,1~n-1中必定存在两个数是相等的。代码#include#include#include#include原创 2018-01-30 08:58:10 · 233 阅读 · 0 评论 -
poj2407(欧拉函数)hdu1695(线性求欧拉函数+容斥原理
题目(欧拉函数poj2407 欧拉函数是小于n的正整数中与n互质的数的数目 直接套欧拉函数公式,即将n素分解后有n=p1^k1*p2^k2*…pm^km,则euler(n)=n(1-1/p1)(1-1/p2)…*(1-1/pm) #include#include#define LL long longLL n;LL solve(LL n){ LL ans=n;原创 2018-01-29 17:58:40 · 218 阅读 · 0 评论 -
2017 Multi-University Training Contest - Team 2 1001 Is Derek lying?
题解:https://zxy160.github.io/原创 2017-07-28 08:54:46 · 211 阅读 · 0 评论 -
矩阵相乘
给两个二维数组表示矩阵,a[n][m],b[x][y] 只有m=x,两个矩阵才能相乘,也就是a[n][m],b[m][p] a数组的第i行和b数组第j列依次相乘的积相加为c数组的c[i][j] 代码#include<stdio.h>int a[2][2];int b[2][3];int c[2][3];int main(){ for(int i=1; i<=2;转载 2017-08-16 13:46:11 · 323 阅读 · 0 评论 -
Codeforces Round #426 (Div. 2) B. The Festive Evening
B. The Festive Evening time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output It’s the end of July – the time when a festive evening is held at原创 2017-07-31 15:07:32 · 469 阅读 · 0 评论 -
玲珑杯”ACM比赛 Round #19 A simple math problem
A – A simple math problem Time Limit:2s Memory Limit:128MByteSubmissions:1577Solved:265DESCRIPTION You have a sequence a n an, which satisfies: Now you should find the value of ⌊ 10 a n原创 2017-07-29 17:57:14 · 257 阅读 · 0 评论 -
2017 计蒜之道 初赛 第三场
在腾讯课堂的物理课上,进行了一个有趣的物理实验。在一个长度为 LL 米的光滑轨道上,小车 A 在 00 时刻以 1\mathrm{m/s}1m/s 的速度从左端出发向右运动,小车 B 在 tt 时刻以 1\mathrm{m/s}1m/s 的速度从右端出发向左运动,两个小车的质量相等。假设所有碰撞都是弹性碰撞,也就是当两个小车相向碰撞时,他们各自会以原来的速度向相反的方向运动;小车和轨道两端发生碰撞时原创 2017-05-28 16:42:44 · 460 阅读 · 0 评论 -
2017 Wuhan University Programming Contest (Online Round) A One car comes and one car goes
A. One car comes and one car goes Two cars from the East Station and the west Station started to drive toward each other, and they met 60 miles away from the East Station first. Both of them kept原创 2017-04-21 16:09:01 · 488 阅读 · 0 评论 -
2017 Wuhan University Programming Contest (Online Round) E Lost in WHU(矩阵快速幂
2017 Wuhan University Programming Contest (Online Round) Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 mebibytes As one of the most beautiful原创 2017-04-21 15:14:18 · 231 阅读 · 0 评论 -
hdu2157 How many ways??(矩阵快速幂
How many ways??Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3136 Accepted Submission(s): 1195Problem Description 春天到了, HDU校园里开满了花, 姹紫嫣红,原创 2017-04-21 13:06:11 · 281 阅读 · 0 评论 -
UESTC - 278 Fibonacci
In the Fibonacci integer sequence, F0=0,F1=1,F0=0,F1=1, and Fn=Fn−1+Fn−2Fn=Fn−1+Fn−2 for n≥2n≥2. For example, the first ten terms of the Fibonacci sequence are:0,1,1,2,3,5,8,13,21,34,⋯0,1,1,2,3,5,8,13,原创 2017-04-20 20:04:53 · 490 阅读 · 0 评论 -
Nearest Neighbor Search(数学题)
链接:https://acm.bnu.edu.cn/v3/statments/52296.pdf 一个点到一个立方体的距离就是到各个边的最短距离#include<stdio.h>int main(){ int x,y,z; int x1,y1,z1; int x2,y2,z2; scanf("%d%d%d",&x,&y,&z); scanf("%d%d%原创 2017-03-16 07:29:00 · 954 阅读 · 0 评论 -
fzu 1050 Number lengths
Problem DescriptionN! (N factorial) can be quite irritating and difficult to compute for large values of N. So instead of calculating N!, I want to know how many digits are in it. (Remember that N! = N原创 2017-03-24 17:26:19 · 348 阅读 · 0 评论 -
fzu 1076 穿越沙漠
Problem Description一辆吉普车来到x公里宽的沙漠边沿A点,吉普车的耗油量为1升/公里,总装油量为500升。通常,吉普车必须用自身油箱中的油在沙漠中设置若干个临时储油点,才能穿越沙漠的。假设在沙漠边沿A点有充足的汽油可供使用,那么吉普车从A点穿过这片沙漠到达终点B,至少要耗多少升油。请编写一个程序,计算最少的耗油量(精确到小数点后3位)。 (1)假设吉普车在沙漠中行进时不发生故障;原创 2017-03-24 14:18:52 · 1403 阅读 · 0 评论 -
抽签原理
箱子中a个黑球,b个白球,求第k次摸出黑球的概率。 (1)对于有放回的。每次都是在a+b个球中任取一个,因此第k次取球有a+b种方法,而第k次取出黑球的方法有a种,所以 概率为p=a/(a+b)。 (2)对于无放回的。把a+b个球摸出来,一共有(a+b)!种方式,而第k次是黑球的方式为 a*(a+b-1)!种方法,所以概率为 p=a*(a+b-1)!/(a+b)!=a/(a+b)...原创 2018-08-20 17:53:13 · 9494 阅读 · 0 评论