- 博客(26)
- 收藏
- 关注
原创 nyoj - 43 24 Point game
24 Point game时间限制:3000 ms | 内存限制:65535 KB难度:5描述There is a game which is called 24 Point game.In this game , you will be given some numbers. Your task is to find an expression w
2017-08-17 16:50:04 217
原创 POJ - 1094 Sorting It All Out
Sorting It All OutTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 35720 Accepted: 12569DescriptionAn ascending sorted sequence of distinct values is one
2017-08-17 10:12:45 173
原创 扩展欧几里得【模板】
扩展欧几里得:求形如ax+by=c方程的特解,并可以扩展出它的通解。ax+by=gcd(a,b);求通解只需要x/gcd(a,b)*c就可以了。模板:long long ex_gcd(long long a,long long b,long long &x,long long &y){ if(b==0) { x=1; y=0;
2017-08-16 15:06:23 169
原创 欧拉函数【模板】
欧拉函数:欧拉函数是小于n的正整数中与n互质的数的数目(φ(1)=1)。直接求欧拉函数: int euler(int n){ //返回euler(n) int res=n,a=n; for(int i=2;i*i<=a;i++){ if(a%i==0){ res=res/i*(i-1);//先进行...
2017-08-16 09:53:14 275
原创 LightOJ - 1282 Leading and Trailing
You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk.InputInput starts with an integer T (≤ 1000), denoting the num
2017-08-15 21:48:26 151
原创 LightOJ - 1370 Bi-shoe and Phi-shoe【欧拉函数的性质】
题目链接:https://cn.vjudge.net/problem/LightOJ-1370题意:给出n个数的欧拉值,求这n个数的和的最小值。欧拉函数:在数论,对正整数n,欧拉函数是小于n的正整数中与n互质的数的数目(φ(1)=1)。性质:欧拉函数是积性函数——若m,n互质, 特殊性质:当n为奇数时, , 证明与上述类似。若n为质
2017-08-15 14:56:20 209
原创 LightOJ - 1234 Harmonic Number【调和级数求和】
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput starts with an integer T
2017-08-15 10:56:50 436
原创 LightOJ - 1259 Goldbach`s Conjecture【素数筛+枚举】
Goldbach`s ConjectureGoldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer, greater than 2, can be expre
2017-08-15 10:33:10 329
原创 素数筛【模板】
埃氏筛法:存储n以内的所有素数int prime[MAX_N];bool is_prime[MAX_N+1];//返回n以内素数的个数int sieve(int n){ int p = 0; for(int i = 0; i<= n; i++) is_prime[i] = true; is_prime[0] = is_prime[1] = false...
2017-08-14 10:36:12 206
原创 快速幂【模板】
typedef long long LL;LL mod_pow(LL x, LL n, LL mod){ LL res = 1; while(n > 0) { if(n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res;}
2017-08-14 09:48:23 160
原创 高精度-小数加法【模板】
题目链接:A+B Problem IV计算400位以内的小数加法模板:#include#include#includeusing namespace std;char str1[405],str2[405];int pre1[405],pre2[405],suf1[405],suf2[405],point1,point2;int main(){ while(~sc
2017-08-12 17:32:01 951
原创 POJ - 1088 滑雪【记忆化搜索】
滑雪Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 100129 Accepted: 38092DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维...
2017-08-12 16:42:46 224
原创 线段树
线段树(1):点修改用一个数组存节点的附加信息,并不需要存储线段的边界,因为每次递归都是严格二分的,所以每次递归到的节点范围都是确定的。节点数量最大为2*n,但数组大小要开到4*n。因为每一层不一定都是满的,虽然这些节点不存在,但依然在数组中占位置。如果当前节点下标为v,那么它的左孩子下标为v*2,右孩子v*2+1。本线段树主要包含3个函数:建树,更新,查找。以查找一段区间内的最大值为例。题目链接...
2017-08-10 10:04:57 277
原创 HDU - 1506 Largest Rectangle in a Histogram
Largest Rectangle in a HistogramTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19158 Accepted Submission(s): 5761Problem Descrip
2017-08-08 20:47:30 365
原创 二叉搜索树【模板】
比普通二叉树添加节点过程多了一个判断。题目链接:The order of a Tree代码:#include#include#includeusing namespace std;int n,flag;typedef struct node{ int data; node *lchild,*rchild;}BiTreeNode,*BiTree;
2017-08-08 09:56:07 685
原创 重建二叉树
给出一棵二叉树的先序遍历和中序遍历,求后序遍历。题目链接:Tree Recovery利用递归构造二叉树的后序遍历。先序遍历特点:根节点->左孩子->右孩子中序遍历特点:左孩子->根节点->右孩子后序遍历特点:左孩子->右孩子->根节点假设先序遍历序列为s1,中序遍历序列为s2,后序遍历序列为s根据先序遍历特点可知s1[0]为当前二叉树的根节点,在中序遍历中找到根...
2017-08-07 19:28:47 185
原创 二叉树的建立与遍历【模板】
二叉树的先序递归建立先序、中序、后序遍历代码:#includeusing namespace std;typedef struct node{ struct node *lchild; struct node *rchild; char data;}BiTreeNode, *BiTree;void createBiTree(BiTree &T){
2017-08-07 14:57:37 610
原创 HDU - 2159 FATE
FATETime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14931 Accepted Submission(s): 7060Problem Description最近xhd正在玩一款叫做FATE的游戏,
2017-08-03 21:21:51 184
原创 石子合并【区间dp】
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=737假设dp[1][4]表示将区间1~4的石子合并所花费的代价。dp[1][4]可以划分为dp[1][1]+dp[2][4]、dp[1][2]+dp[3][4]、dp[1][3]+dp[4][4]
2017-08-03 10:52:40 300
原创 nyoj-745 蚂蚁的难题(二)
蚂蚁的难题(二)时间限制:1000 ms | 内存限制:65535 KB难度:3描述下雨了,下雨了,蚂蚁搬家了。已知有n种食材需要搬走,这些食材从1到n依次排成了一个圈。小蚂蚁对每种食材都有一个喜爱程度值Vi,当然,如果Vi小于0的时候,表示蚂蚁讨厌这种食材。因为马上就要下雨了,所以蚂蚁只能搬一次,但是能够搬走连续一段的食材。时间紧急,你快帮帮小蚂蚁吧,
2017-08-03 08:43:53 418
原创 nyoj-740 “炫舞家“ST
“炫舞家“ST时间限制:3000 ms | 内存限制:65535 KB难度:3描述ST是一个酷爱炫舞的玩家。TA很喜欢玩QQ炫舞,因此TA也爱屋及乌的喜欢玩跳舞机(Dance Dance Revolution,DDR)。但是TA每天还要努力的学习,因此TA希望每次都保存最多的体力来学习。DDR的主要内容是用脚来踩踏板。踏板有4个方向的箭头,用1,2,3,4来代表
2017-08-02 21:32:02 334 2
原创 HDU - 1421 搬寝室
搬寝室Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29055 Accepted Submission(s): 9962Problem Description搬寝室是很累的,xhd深有体会.时间追述2
2017-08-02 19:58:25 194
原创 HDU - 1864 最大报销额
最大报销额Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 26098 Accepted Submission(s): 8007Problem Description现有一笔经费可以报销一定额度的发票。允
2017-08-02 10:25:33 211
原创 HDU - 3466 Proud Merchants
Proud MerchantsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 6755 Accepted Submission(s): 2814Problem DescriptionRecently,
2017-08-01 21:25:08 184
原创 HDU-2546 饭卡【线性dp】
饭卡Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 31001 Accepted Submission(s): 10627Problem Description电子科大本部食堂的饭卡有一种很诡异的设计,
2017-08-01 17:10:20 340
原创 nyoj-37 回文字符串
回文字符串时间限制:3000 ms | 内存限制:65535 KB难度:4描述所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba"。当然,我们给你的问题不会再简单到判断一个字符串是不是回文字符串。现在要求你,给你一个字符串,可在任意位置添加字符,最少再添加几个字符,可以使这个字符串成为回文字符串。输入第一行给出整数N(0
2017-08-01 10:10:46 181
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人