数学
闻道-问道
这个作者很懒,什么都没留下…
展开
-
Prime Gap (素数)
Problem DescriptionThe sequence of n 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbersp and p + n is called a p原创 2017-08-11 21:36:21 · 328 阅读 · 0 评论 -
小a与黄金街道(欧拉函数求和)
链接:https://ac.nowcoder.com/acm/contest/317/D来源:牛客网 题目描述小a和小b来到了一条布满了黄金的街道上。它们想要带几块黄金回去,然而这里的城管担心他们拿走的太多,于是要求小a和小b通过做一个游戏来决定最后得到的黄金的数量。游戏规则是这样的:假设道路长度为nn米(左端点为00,右端点为nn),同时给出一个数kk(下面会提到kk的用法)设...原创 2019-01-22 19:58:35 · 438 阅读 · 0 评论 -
Game of Taking Stones(java大数高精度)
Two people face two piles of stones and make a game. They take turns to take stones. As game rules,there are two different methods of taking stones: One scheme is that you can take any number of ston...原创 2018-10-03 17:21:03 · 285 阅读 · 0 评论 -
B. Weakened Common Divisor(筛质因子)
During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list...原创 2018-08-20 11:06:28 · 335 阅读 · 0 评论 -
#1789 : 阶乘问题
描述给定 n, k,求一个最大的整数 m,使得 km 是 n! 的约数输入第一行两个正整数 n, k2 ≤ n,k ≤ 109输出输出最大的 m样例输入5 2样例输出3思路:先分解质因数,然后,求出n!中的这些素因数分别由多少,相除后,随处整体有多少,取最小值就好了。代码:#include <bits/stdc++.h>#...原创 2018-08-07 11:05:55 · 324 阅读 · 0 评论 -
Problem B. Harvest of Apples(预处理+莫队)
Problem DescriptionThere are n apples on a tree, numbered from 1 to n.Count the number of ways to pick at most m apples.InputThe first line of the input contains an integer T (1≤T≤105) denoting...原创 2018-08-02 10:29:30 · 411 阅读 · 2 评论 -
托米的游戏(期望+逆元)
题目描述题目背景编不下去了托米有一棵有根树 T, 树根为1,每轮他会在剩下的子树中等概率一个点 u, 砍掉 u 的子树 (包含 u),如果树上的点都被砍光了,游戏结束。求出这个游戏进行的期望轮数,可以证明这个数一定是有理数,设他为 , 你需要告诉他一个整数 x 满足 输入描述:第一行输入一个数 n, 表示 T 的点数,下面 n-1 行给出了 T 的每条边输出描述:一行一...原创 2018-08-01 11:01:58 · 356 阅读 · 0 评论 -
阶乘(factorial)(分块)
链接:https://www.nowcoder.com/acm/contest/135/D来源:牛客网 题目描述输入描述:输入数据共一行,一个正整数n,意义如“问题描述”。输出描述:输出一行描述答案:一个正整数k,表示S的末尾有k个0 示例1输入复制10输出复制7说明 之前学习过分块,刚好用这道题试一下。...原创 2018-07-22 21:38:18 · 355 阅读 · 0 评论 -
数论模板
筛素数void init() //nlogn{ memset(su,0,sizeof(su)); su[1]=1; for(int i=2;i<=n;i++) for(int j=i*2;j<=n;j+=i) su[j]=1;}void init1() //优化{ memset(su,0,sizeof(su))...原创 2018-06-24 21:37:19 · 236 阅读 · 0 评论 -
求值2(组合数平方和)
题目描述 Ans = 0; For(inti = 1; i <= n; i++) For(int v = 0; v <= n; v++) Ans = (Ans + C(i, v) * C(i, v)) % 998244353;C(i,v)为组合数第i行第v列的数。给你上面的代码中的n,请你输出Ans的值。输入描述:输入一个整数n输出描述:输出Ans的值。示例1输...原创 2018-06-12 11:58:34 · 3287 阅读 · 0 评论 -
C. Finite or not?(gcd 数论)
C. Finite or not?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given several queries. Each query consists of three integers pp, qq and bb...原创 2018-05-21 20:58:44 · 269 阅读 · 0 评论 -
Facing Problem With Trees (卡特兰数变形+java大数)
In this problem you are to find the number (Let P) of ordered trees where each of the tree consists ofexactly m edges and each of the nodes has out-degree either exactly two or zero and the root has e...原创 2018-05-19 18:59:10 · 233 阅读 · 0 评论 -
FZU - 2278(直接法求期望)
Yinyangshi is a famous RPG game on mobile phones.Kim enjoys collecting cards in this game. Suppose there are n kinds of cards. If you want to get a new card, you need to pay W coins to draw a card. Ea...原创 2018-04-27 20:09:13 · 219 阅读 · 0 评论 -
小a的学期(组合数很大,取模不为质数)
链接:https://ac.nowcoder.com/acm/contest/317/H来源:牛客网 题目描述小a是一个健忘的人,由于他经常忘记做作业,因此老师对他很恼火。小a马上就要开学了,他学期一共2n天,对于第ii天,他有可能写了作业,也可能没写作业,不过他自己心里还有点B数,因此他会写恰好n天的作业现在,小a需要安排他的学期计划,如果小a的学期中存在一天x,在这之前的x天中...原创 2019-02-02 20:47:25 · 623 阅读 · 0 评论