![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数学_杂
wang2147483647
这个作者很懒,什么都没留下…
展开
-
URAL 2070 Interesting Numbers(数学)
题目地址:http://acm.timus.ru/problem.aspx?space=1&num=2070思路:质数一定满足题意(满足条件一,因子数为2为质数)。所以只需求出l到r中的合数且因子数为质数的数的个数。该数质因子只能为1(若大于一,则因子数为合数),所以枚举每个质数,若该质数的指数+1(因子数)为质数,则ans--。#include#include#include#in原创 2016-08-22 20:17:01 · 978 阅读 · 0 评论 -
Codeforces Round #244 (Div. 2) E. Police Patrol(数学)
题目地址:http://codeforces.com/problemset/problem/427/E思路:显然,位置选在所有数的中位数时距离最短。则从两头取,累计和即可。#include#include#include#includeusing namespace std;typedef long long LL;const int maxn=1e6+50;LL ans;原创 2016-07-27 16:36:22 · 594 阅读 · 0 评论 -
Codeforces Round #201 (Div. 1) A. Alice and Bob(数学)
题目地址:http://codeforces.com/problemset/problem/346/A思路:最终无法再选择两个数,说明最后形成了一个公差为d的等差数列,即为d,d+d,d+2*d,……,d+(n-1)*d 。所以,只需求出原始数列所有数的最大公约数即可求出公差。最终数列元素个数=数列元素最大值/公差,减去n即为比赛过程中新增加的元素。由于A先开始游戏,所以如果新增加元素为奇数则原创 2016-07-26 21:16:55 · 547 阅读 · 0 评论 -
Codeforces Round #305 (Div. 1) A. Mike and Frog(数学)
题目地址:http://codeforces.com/problemset/problem/547/A思路:找循环节。%m的余数有m种,pos1表示a1第一次出现的时间,pos2表示a2第一次出现的时间,l1表示第一个循环长度,l2表示第二个循环长度。循环节长度最大为m,所以最大需模拟2*m次,pos1#include#include#include#include#include原创 2016-07-26 10:57:55 · 578 阅读 · 0 评论 -
Codeforces Round #199 (Div. 2) C. Cupboard and Balloons(数学)
题目地址:http://codeforces.com/problemset/problem/342/C思路:(1)h%r(2)h%r>=r/2&&h%r(3)h%r>=sqrt(3)*r/2,上面放3个#include#include#includeusing namespace std;long long r,h;int main(){ scanf("%I原创 2016-07-26 09:44:49 · 430 阅读 · 0 评论 -
Codeforces 765D Artsem and Saunders(数学)
题目地址:http://codeforces.com/contest/765/problem/D思路:g(h(x))=x 1h(g(x))=f(x) 1由(2)得h(g(h(x)))=f(h(x)),由(1)得h(g(h(x)))=h(x),则h(x)=f(h(x)) (3)同理,由(1)得,g(h(g(x)))=g(x),由(2)得,g(h(g(x)))=g(f(x原创 2017-02-14 22:19:51 · 460 阅读 · 0 评论 -
UVA 11538 Chess Queen(数学)
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=27&page=show_problem&problem=2533思路:同一行中放置皇后即为n*A(m,2),同一列中放置皇后即为m*A(n,2)。对角线上放置皇后:设n不大于m,则所有主对角线格子个数为1,2,3....n-1原创 2017-05-18 15:33:57 · 778 阅读 · 0 评论 -
UVA 11806 Cheerleaders(容斥原理)
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2906思路:A表示第一行无石子,B表示最后一行无石子,C表示第一列无石子,D表示最后一列无石子。A=B=c[(n-1)*m][k],C=D=c[n*(m-1)][k]。tot=c[n*m][k原创 2017-05-18 15:43:21 · 794 阅读 · 0 评论 -
UVA 11375 Matches(递推)
题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2370思路:mat[x]表示数字x所需的火柴数,则当有i根火柴时,每添加一个数字x,就行状态i转移到状态i+mat[x]。令d[i]表示状态i个火柴时的方案数,则每次从原创 2017-05-18 22:32:04 · 792 阅读 · 0 评论