
数学
文章平均质量分 54
sdau_blue
念念不忘,必有回响。驰而不息,功不唐捐。
展开
-
快速幂(板题)
一.快速幂的引入1.关于取模运算:(a*b)%c=(a%c)*(b%c)%c2.模板:int quick(int a,int b,int c) { int ans=1; //记录结果 a=a%c; //预处理,使得a处于c的数据范围之下 while(b!=0) { if(b&1) ans=(ans*a)%c; ...原创 2018-04-30 11:27:21 · 351 阅读 · 0 评论 -
石子游戏(博弈+乱猜)
链接:https://www.nowcoder.com/acm/contest/186/A来源:牛客网 题目描述Alice和Bob在玩游戏,他们面前有n堆石子,对于这些石子他们可以轮流进行一些操作,不能进行下去的人则输掉这局游戏。可以进行两种操作:1. 把石子数为奇数的一堆石子分为两堆正整数个石子2. 把两堆石子数为偶数的石子合并为一堆两人都足够聪明,会按照最优策略操作。现在A...原创 2018-09-15 10:34:31 · 3159 阅读 · 2 评论 -
HDU-5974-A Simple Math Problem(数论)
大体题意:给你a和b,让你求出X和Y,使得X + Y = a lcm(x,y) = b思路:看数据范围肯定不能进行暴力枚举了!令gcd(x,y) = g;那么g * k1 = x;g * k2 = y;因为g 是最大公约数,那么k1与k2 必互质!=> g*k1*k2 = b=> g*k1 + g * k2 = a;所以k1 *...原创 2018-10-03 16:58:13 · 251 阅读 · 0 评论 -
C - Recursive sequence(矩阵快速幂)
题目大意:f(n+1)=2*f(n-1)+f(n)+(n+1)^4f(1)=a;f(2)=b;求第n项。要mod思路:裸的。。。构造矩阵附上队友丑陋优秀的代码:#include<bits/stdc++.h>///#define mod 2147493647using namespace std;typedef long long ll;const ...原创 2018-10-06 20:06:10 · 406 阅读 · 0 评论 -
Great Cells (数学+思维)
题目:https://cn.vjudge.net/problem/Gym-101194H题目大意:有一张N*M的格子纸,每个格子可以填1到K之间的数。如果一个格子里的数严格大于本行的其他格子里的数,并且严格大于本列的的其他格子里的数,则这个格子叫做Great Cell。Ag表示有Ag种填法使得格子纸中恰有g个Great Cell。思路:这道题要整体考虑。首先,先把式子拆开,然后...原创 2018-10-07 18:39:07 · 378 阅读 · 0 评论 -
HDU 6265 - 2017 China Collegiate Programming Contest, Hangzhou - B.Master of Phi -(欧拉函数,公式化简)
终于想明白了啊啊啊啊啊。不容易的啊啊啊啊啊啊。明天再补题解:#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll mod=998244353; ll m,ans,n,a,all,j,k,p[30],q[30],tt[30]; ll fpow(ll n,ll k)//快速...原创 2018-10-18 22:16:13 · 325 阅读 · 0 评论 -
hdu6267 Master of Random(期望)
比赛的时候是队友推的。但是赛后想了想这种题找到方向了,就不该推那么长时间。思路:一看,所有情况都枚举一遍显然是不合理的 。那么我就去转化思维,想每一个点对总答案的贡献。(很多题都是这个想法。)推导过程:还要乘以权值。代码:#include<bits/stdc++.h>using namespace std;typedef ...原创 2018-10-20 09:02:50 · 436 阅读 · 0 评论 -
zoj3987 Numbers(大数+贪心)
NumbersTime Limit: 2 Seconds Memory Limit: 65536 KBDreamGrid has a nonnegative integer . He would like to divide into nonnegative integers and minimizes their bitwise or (i.e. and should be...原创 2018-10-25 21:37:12 · 308 阅读 · 2 评论 -
A - Play the Dice(期望)
A - Play the Dice时间限制: 2000 MS 内存限制: 65535 MB 问题描述There is a dice with N sides, which are numbered from 1,2,...,n and have the equal possibility to show up when one rolls a dice. Each si...原创 2018-10-21 15:37:34 · 184 阅读 · 0 评论 -
灰魔法师
链接:https://www.nowcoder.com/acm/contest/215/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述“White shores, and beyond. A far green country under a swift su...原创 2018-10-27 16:53:10 · 253 阅读 · 0 评论 -
D. New Year and the Permutation Concatenation(打表找规律)
http://codeforces.com/contest/1091/problem/DD. New Year and the Permutation Concatenationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstanda...原创 2019-01-01 16:49:08 · 789 阅读 · 2 评论 -
C. New Year and the Sphere Transmission
http://codeforces.com/contest/1091/problem/CC. New Year and the Sphere Transmissiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard o...原创 2019-01-01 17:00:13 · 497 阅读 · 2 评论 -
筱玛的快乐 (素数线性筛)
筛素数详见:https://www.cnblogs.com/Miroerwf/p/7776390.html题目链接:https://ac.nowcoder.com/acm/contest/342/A素数线性筛。写这篇博客是为了写一下,这道题卡素数筛,第一次用,没有裸敲过,一直用的n*sqrt(n)复杂度的。这里的是0(n)筛法。(lala())本题比较卡时间,还要用printf...原创 2019-01-11 22:40:21 · 293 阅读 · 0 评论 -
Empty Convex Polygons(最大空凸包&&模板)
Empty Convex PolygonsTime Limit: 16000/8000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 581 Accepted Submission(s): 149 Problem DescriptionGiven a se...原创 2018-09-18 21:22:20 · 1007 阅读 · 0 评论 -
L. Poor God Water
L:暂存,未懂。高大佬写的。#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll mod=1e9+7;const ll M=9;ll N;struct Matrix{ Matrix(){memset(a,0,sizeof(a));} ll a[M][...原创 2018-09-15 20:40:05 · 296 阅读 · 0 评论 -
牛客暑假多校——A-Ternary String(找规律+欧拉降幂)(模板)
链接:https://www.nowcoder.com/acm/contest/142/A来源:牛客网题目描述A ternary string is a sequence of digits, where each digit is either 0, 1, or 2.Chiaki has a ternary string s which can self-reproduce. Eve...原创 2018-07-29 11:02:30 · 308 阅读 · 0 评论 -
hdu -2837(指数循环节+欧拉函数)
转自:https://blog.youkuaiyun.com/wust_cyl/article/details/77424953Problem DescriptionAssume that f(0) = 1 and 0^0=1. f(n) = (n%10)^f(n/10) for all n bigger than zero. Please calculate f(n)%m. (2 ≤ n , m ≤...转载 2018-07-29 11:18:59 · 252 阅读 · 0 评论 -
Generation i(排列组合 或 隔板)
链接:https://www.nowcoder.com/acm/contest/144/C来源:牛客网题目描述Oak is given N empty and non-repeatable sets which are numbered from 1 to N.Now Oak is going to do N operations. In the i-th operation, he ...原创 2018-08-04 21:14:25 · 326 阅读 · 0 评论 -
最长回文(Manacher算法 模板)
Manacher算法是个好东西~~~最长回文Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 29068 Accepted Submission(s): 10575 Problem Description给出一个只由...原创 2018-08-05 11:32:58 · 157 阅读 · 0 评论 -
Hotaru's problem(manacher+思维)好题!!
Hotaru's problemTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 4234 Accepted Submission(s): 1384Problem DescriptionHotaru Ichijou rec...原创 2018-08-05 15:33:35 · 438 阅读 · 0 评论 -
Manacher算法详解
Manacher算法转自:http://www.cnblogs.com/z360/p/6375514.html算法总结第三弹 manacher算法,前面讲了两个字符串相算法——kmp和拓展kmp,这次来还是来总结一个字符串算法,manacher算法,我习惯叫他 “马拉车”算法。相对于前面介绍的两个算法,Manacher算法的应用范围要狭窄得多,但是它的思想和拓展kmp算法有很多共通支出...转载 2018-08-05 20:17:02 · 144 阅读 · 0 评论 -
gpa——01分数规划
链接:https://www.nowcoder.com/acm/contest/143/A来源:牛客网题目描述Kanade selected n courses in the university. The academic credit of the i-th course is s[i] and the score of the i-th course is c[i].At th...原创 2018-08-02 20:51:48 · 386 阅读 · 0 评论 -
The shortest problem
The shortest problemTime Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2571 Accepted Submission(s): 1017Problem DescriptionIn this proble...原创 2018-08-07 15:51:53 · 156 阅读 · 0 评论 -
Find Integer(费马大定理+勾股数)
Find IntegerTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1029 Accepted Submission(s): 251Special Judge Problem Descriptionpeople i...原创 2018-08-26 17:46:12 · 303 阅读 · 0 评论 -
CRB and Tree(树形+异或性质)
CRB and Treehttp://acm.hdu.edu.cn/showproblem.php?pid=5416Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2411 Accepted Submission(s): 7...原创 2018-08-17 10:34:23 · 435 阅读 · 0 评论 -
B. Weakened Common Divisor(筛质因子)
http://codeforces.com/contest/1025/problem/BB. Weakened Common Divisortime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring...原创 2018-08-20 15:54:56 · 294 阅读 · 0 评论 -
Tree and Permutation(排列组合+树)好题!
Tree and Permutationhttp://acm.hdu.edu.cn/showproblem.php?pid=6446Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1155 Accepted Submissi...原创 2018-08-27 21:42:38 · 603 阅读 · 0 评论 -
大水题(容斥原理)
链接:https://ac.nowcoder.com/acm/challenge/terminal来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述给出一个数n,求1到n中,有多少个数不是2 5 11 13的倍数。输入描述:本题有多组输入每行一个数n,1&l...原创 2019-02-03 20:14:41 · 437 阅读 · 0 评论