![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Algorithm
琳小白
这个作者很懒,什么都没留下…
展开
-
九度1161——Repeater
原题http://ac.jobdu.com/problem.php?pid=1161 题目描述: Harmony is indispensible in our daily life and no one can live without it—-may be Facer is the only exception. One day it is rumored that repeat paint原创 2016-03-31 12:11:02 · 1771 阅读 · 1 评论 -
Codeforces#228 (Div. 1)A_贪心
Fox and Box AccumulationFox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we’ll call xi th原创 2016-08-25 15:04:09 · 419 阅读 · 0 评论 -
Codeforces#385C_素数打表+dp
素数打表方法void init_prim(){ memset(vis,1,sizeof(vis)); for(int i=2; i<=MM; i++) { if(vis[i]) { if(cnt[i])dp[i]+=cnt[i]; for(int j=i*2; j<=MM; j+=i)原创 2016-08-24 20:33:03 · 405 阅读 · 0 评论 -
Codeforces#414B——Mashmokh and ACM
Mashmokh’s boss, Bimokh, didn’t like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh’s team. I原创 2016-08-18 13:42:31 · 657 阅读 · 0 评论 -
Codeforces#371
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of th原创 2016-08-20 15:00:23 · 496 阅读 · 0 评论 -
子集生成
给出一个集合,生成该集合的任意子集。# include<cstdio># include<iostream>using namespace std;void subset(int n,int* a,int cur){ if(n==cur) { for(int i=1; i<=n; i++) if(a[i-1]) cout<<i<<" "原创 2016-08-17 22:10:29 · 462 阅读 · 0 评论 -
0-1背包
https://www.bnuoj.com/v3/problem_show.php?pid=4183 给定n种物品和一背包。物品i的重量是wi,其价值为vi,背包的容量为C。问应如何选择装入背包的物品,使得装入背包中物品的总价值最大?在选择装入背包的物品时,对每种物品i只有两种选择,即装入背包或不装入背包。不能将物品i装入背包多次,也不能只装入部分的物品i。Input 第一行 n C , 表示原创 2016-07-17 12:38:35 · 587 阅读 · 0 评论 -
队列和栈
卡片游戏桌上有一叠牌,从第一张牌(即位于顶面的牌)开始从上往下一次编号为1-n。当至少还剩两张牌时进行以下操作:把第一张牌扔掉,然后把新的第一张放到整叠牌的最后。输入n,输出每次扔掉的牌,以及最后剩下的牌。 样例输入:7 样例输出:1 3 5 7 4 2 6# include<iostream># include<queue>using namespace std;queue<int> q原创 2016-07-16 21:24:14 · 365 阅读 · 0 评论 -
vs2012编译c语言-指针不能判NULL
这段代码codeblocks能正常运行,vs2012中运行时eval时报出错误,原因在于空指针不能判空。 做个小测试,给p4分配空间,其他什么都不做,按理说p4->l和p4->r都是null,测试显示都不是null。 把代码搬到codeblocks中,能判空,正常运行。 结论:编译器不一样,政策可能就不一样;vs中应该用别的方法来判空。小测试int flag=0; struct as原创 2015-11-24 11:50:42 · 868 阅读 · 0 评论 -
星期几问题
参考九度OJ 1043 题目描述: We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400. For example, years 2004, 2180原创 2016-03-07 23:08:10 · 557 阅读 · 0 评论 -
打印日期
九度OJ题目1186:打印日期题目描述: 给出年分m和一年中的第n天,算出第n天是几月几号。 输入: 输入包括两个整数y(1<=y<=3000),n(1<=n<=366)。 输出: 可能有多组测试数据,对于每组数据, 按 yyyy-mm-dd的格式将输入中对应的日期打印出来。 样例输入: 2000 3 2000 31 2000 40 2000 60 2000 61 2001原创 2016-03-07 23:52:26 · 855 阅读 · 0 评论 -
九度1088——剩下的树
九度1088 题目描述: 有一个长度为整数L(1<=L<=10000)的马路,可以想象成数轴上长度为L的一个线段,起点是坐标原点,在每个整数坐标点有一棵树,即在0,1,2,…,L共L+1个位置上有L+1棵树。 现在要移走一些树,移走的树的区间用一对数字表示,如 100 200表示移走从100到200之间(包括端点)所有的树。 可能有M(1<=M<=100)个区间,区间原创 2016-03-12 20:25:05 · 655 阅读 · 0 评论 -
回溯法
1,八皇后问题# include<iostream>using namespace std;int a[10];int cnt=0;bool judge(int cur,int num){ for(int i=1; i<cur; i++) if(num==a[i]||(i+a[i])==(cur+num)||(i-a[i])==(cur-num))原创 2016-09-20 14:00:57 · 817 阅读 · 0 评论