自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

null

null

  • 博客(40)
  • 资源 (8)
  • 收藏
  • 关注

原创 1005Number Sequence

考察鸽巢原理的应用,数字的取值有k种可能的话,这样的数字取n位组成的n位序列有k^n中可能的排列,任取n+k^n位数字组成一个序列,里面有k^n+1个n位排列,其中一定有重复的。好比有10种颜色的玻璃球,放在11个盒子里,必定有两个球的颜色一样。这里取值范围是0~6共7个,在f的序列中任取两个数的排列有49种(带入公式得51=2+7^2)那么在f[51]的时候必定已经有了循环。因为51个数字需

2014-07-21 15:10:24 380

原创 1004Let the Balloon Rise

#include#include#include#includeusing namespace std;struct node{ string st;int cnt; node(string s,int k=1):st(s),cnt(k){} node(){} bool operator<(const node&x)const{return cnt<x.

2014-07-21 12:14:02 306

原创 1003

#include#include#includeusing namespace std;int main(){    int n;cin>>n;    for(int i=1;i    {        if(i!=1)cout        printf("Case %d:\n",i);        int cnt;cin>>cnt;     

2014-07-20 21:59:30 455

原创 A + B Problem II

两个正的大数相加,HDOJ的每个输出

2014-07-20 20:33:25 298

原创 1033. To Fill or Not to Fill

看当前站可达范围内的加油站,加足够的油到第一个更便宜的站,或者加满油到紧邻的下一个站#include#includeusing namespace std;int cmax,dist,davg,n;double cost,leftoil,maxlen;struct node{int d; double p; node(double a,int b):p(a),d(b){} b

2014-07-20 17:10:58 344

原创 1049. Counting Ones

我实在编程之美上看的答案,看完后感觉mingmingshi

2014-07-19 11:08:36 371

原创 1064. Complete Binary Search Tree

问如何简便地用一个有序序列生成一个平衡二叉树1.给定一个数字n,能否生成一个n个节点的完全二叉树?——能2.这个生成的完全二叉树,能否以中序遍历?——能,它只是一个使用数字控制结点数目的普通二叉树,与一般二叉树并无不同3.平衡二叉树与有序序列有何共同之处——BST的中序遍历也是一个有序序列#include#include#include#includeusing

2014-07-18 22:24:18 350

原创 1066. Root of AVL Tree

#include#includeusing namespace std;struct node{ node*lch,*rch; int key; node(int x):key(x){lch=rch=nullptr;}};using ptr=node*;int deep(ptr p){ if(!p)return 0; return max(d

2014-07-17 20:14:45 316

原创 二叉平衡树AVL插入删除操作的实现

这里有左旋,右旋,左右旋,右左xuanzh

2014-07-17 15:08:02 553

原创 二叉排序树插入删除的实现

二叉排序树的函数只有三个,插入,查找,删除

2014-07-17 09:26:52 398

原创 线性时间素数筛

普通的素数筛原理就是:所有素数的倍数(2倍以上)为

2014-07-16 18:54:56 465

原创 1051. Pop Sequence

保持当前遇到的最大值,小于此最大值的最小值,小于等于此最大值的数字个数,当出现一个新的最大值,其右侧(即随后出栈的)比它小的数字是降序的,总个数不能超出容量,复杂度O(n)#include#includeusing namespace std;int m,n,k,val[2222];int main(){ cin>>m>>n>>k; while(k--){ int mm

2014-07-15 20:13:27 286

原创 1050. String Subtraction

#include#include#includeusing namespace std;int main(){ string st,s; getline(cin,st); getline(cin,s); vectorhas(300,false); for(char c:s)has[c]=true; for(char c:st)if(!has

2014-07-14 16:22:03 418

原创 1065. A+B and C (64bit)

检测int加法溢出用(a>0&&b>0&&b>INT_MAX-a) ||(along long范围是[-2^63, 2^63),但这里的范围是[-2^63, 2^63],如果对于a,b,c分别为2^63 ,0,2^63的情况,long long 根本就不能存这种数,所以用long long 来做这个题是不对的,必须自己做一个大整数的加减法或用java等的大整数功能

2014-07-14 16:11:56 295

原创 1083. List Grades

#include#include#include#includeusing namespace std;struct node{ node(){} node(int x):goal(x){} string name,id;int goal; bool operator<(const node&x)const{return goal<x.goal;}};

2014-07-14 10:44:02 314

原创 1081. Rational Sum

定义一个结构及其加法#includeusing namespace std;struct node{ long num,den; node(int a,int b):num(a),den(b){} node operator+(node x) { long _n=num*x.den+den*x.num; long _d=de

2014-07-14 09:33:53 304

原创 1063. Set Similarity

二路归并#include#includeusing namespace std;set val[60];int main(){ int n;cin>>n; for(int i=1,cnt,k;i<=n;++i){ cin>>cnt; while(cnt--){ cin>>k; val[i].insert(k); } } cin>>n; while(n

2014-07-13 16:48:35 293

原创 1053. Path of Equal Weight

dfs#include#include#includeusing namespace std;int n,m,pay,val[105];vectoradj[105],path;vector>ret;void dfs(int k,int wei){ path.push_back(val[k]); if(adj[k].empty()){ if(wei==pay) re

2014-07-13 13:24:53 322

原创 1056. Mice and Rice

#include#include#includeusing namespace std;int n,k;int main(){ cin>>n>>k; vectorord(n),wei(n),rnk(n); for(auto&x:wei)cin>>x; for(auto&x:ord)cin>>x; while(ord.size()>1){ int grp=ord

2014-07-13 10:23:59 300

原创 1059. Prime Factors

找素数最好用一个素数筛,

2014-07-12 22:58:29 276

原创 1062. Talent and Virtue

#include#includeusing namespace std;struct node{ int id,vir,tal,sum; node(int a,int b,int c):id(a),vir(b),tal(c),sum(b+c){} bool operator<(const node&x)const { if(sum!=x.su

2014-07-12 22:10:04 382

原创 1061. Dating

#include#includeusing namespace std;char*day[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};bool ishour(char c){return c>='0'&&c='A'&&c<='N';}bool isday(char c){return c>='A'&&c<='G';}int main()

2014-07-12 20:40:32 268

原创 1057. Stack

这个题网上都是用树形数组做的。要正确写出树形数组和lower_bound的代码。用树形数组关键是0这个下标是不能用的,因为lowerbit(0)为0会死循环,因此用lower_bound(l,r,x)查找时l不能从0而应从1开始。#include#includeusing namespace std;const int N=100003;stackst;int sm[N];int

2014-07-12 12:45:52 304

原创 1045. Favorite Color Stripe

问题抽象为求序列x、y的lcs,但一个x中的元素可以对应多个y中的元素。对基本的lcs问题方法稍作修改即可。在基本的lcs问题中求len(i , j)时,若x[i]==y[j],len(i,j)一定比len(i-1,j-1)大1。在这里len(i,j)一定比len(i,j-1)大1,因为当y中前一个匹配元素为x[i],应该len(i,j-1)加上1,不为x[i],也应该len(i,j-1)加上

2014-07-09 21:12:16 330

原创 1055. The World's Richest

考察多路排序,可以自己排,也可以用一个d

2014-07-09 16:07:15 329

原创 6-10. 关键活动

所谓关键路径就是DAG的最长路径#include#include#include#includeusing namespace std;struct edge{ int from,to,no; edge(int a,int b,int c):from(a),to(b),no(c){} bool operator<(const edge&x)const

2014-07-09 11:42:32 320

原创 1067. Sort with Swap

#includeusing namespace std;int n,pos[100002], cnt;void set0(){ while(pos[0]){ int tmp=pos[0]; pos[0]=pos[tmp], pos[tmp]=tmp; ++cnt; }}int main(){ scanf("%d",&n); for(int i=0,

2014-07-06 19:47:48 294

原创 1068. Find More Coins

01背包,最小字典序结果,恰好填满,照顾好这三点就行了,背包九讲里有说的#include#includeusing namespace std;const int N=10003,V=103;int n,m,pack[V],used[N][V],wei[N];int main(){ fill_n(pack+1,V-1,-1<<30); cin>>n>>m; for(int

2014-07-06 18:53:59 323

原创 1069. The Black Hole of Numbers

没有说一定是4为数字#include#include#includeusing namespace std;string step(string st){ sort(st.begin(),st.end()); string ss(st.size(),0); using RI=reverse_iterator; copy(st.begin(),st.en

2014-07-04 23:03:28 332

原创 1080. Graduate Admission

#include#include#includeusing namespace std;struct node{ int ge,gi,gf,want[5],no; bool operator<(const node&x)const { if(x.gf!=gf)return gf>x.gf; return ge>x.ge; }

2014-07-04 22:16:05 346

原创 1071. Speech Patterns

#include#include#include#include#includeusing namespace std;typedef const pair E;typedef unordered_map EQ;int main(){ string s; getline(cin,s); for(auto&x:s) x=(isalnum(x)?tolower(x):' '

2014-07-04 19:29:07 306

原创 1073. Scientific Notation

#include#includeusing namespace std;int main(){ if(cin.get()=='-') cout<<'-'; string st; int k; getline(cin,st,'E'); cin>>k; if(k<0) { st.erase(1,1); st="0."

2014-07-04 18:33:46 321

原创 1079. Total Sales of Supply

cout)<<endl)<<endl)<<endl)<<endl<<sizeof(string)<<endl)<<endl)的结果:

2014-07-03 22:29:06 362

原创 1044. Shopping in Mars

这个题表面好像是用部分和求任意区间val[ i~j ]内的数字和,但那样是O(n*n),用顺序扫描的方法是O(n)复杂度#include#includeusing namespace std;int val[100003],pay,n,mmin=1<<30, sum=0;vector>posp;int main(){ scanf("%d%d",&n,&pay); for(in

2014-07-03 21:18:28 318

原创 1054. The Dominant Color

#include#include#include#include#includeusing namespace std;int main(){    unordered_mapcnt;    int n,m;    cin>>n>>m;    for(int i=0;i        for(int t,j=0;j        {     

2014-07-03 16:57:39 314

原创 1076. Forwards on Weibo

#include#include#include#includeusing namespace std;deque >ed;int l,n,m;int post(int k){ int cnt=0; vectorused(n+1); vectordeep(n+1); queueque; que.push(k); used[k]=tru

2014-07-03 15:24:28 333

原创 1077. Kuchiguse

#include#include#includeusing namespace std;string suf(string&x,string&y){ dequet; for(int i=x.size()-1,j=y.size()-1;i>=0&&j>=0;--i,--j) { if(x[i]==y[j]) t.push_fr

2014-07-03 14:34:13 333

原创 1037. Magic Coupon

#include#includeusing namespace std;int main(){ int n; priority_queue,less>maxa,maxb; priority_queue,greater>mina,minb; cin>>n; for(int k,i=0;i<n;++i){ cin>>k; if(k>=0)maxa.push(k

2014-07-03 14:00:20 290

原创 1038. Recover the Smallest Number

#include#include#include#includeusing namespace std;typedef const string & csr;int main(){ vectorvs; int n,i; cin>>n; while(n--){ string s; cin>>s; vs.push_back(s); } sort(vs.begin(),v

2014-07-03 13:24:19 271

原创 1075. PAT Judge

#include#include#includeusing namespace std;struct node{ int id,sum,h[6],ok,well,r; bool operator<(const node&x)const { if(ok!=x.ok) return ok>x.ok; if(sum!=x.sum)

2014-07-01 15:21:27 308

ffmpeg-win64-shared&static;.zip

ffmpeg的x64可执行文件,包括static版本和shared版本

2019-09-29

Learn Windows PowerShell 3 in a Month of Lunches, 2nd Edition.pdf

Learn Windows PowerShell 3 in a Month of Lunches

2017-01-05

MinGW5.1.6_X86.zip

x86下的MinGW,全套工具链,省得到处找了

2016-06-16

emacs_23.1.0.0

windows X64下emacs,编译器还是emacs好用

2015-05-04

redis-2.8.19源码

redis工程源码,在src文件夹里,研究源码的童鞋可以看看

2015-05-04

mingw gcc/g++_for_windowsX64

X64下mingw,g++版本4.9,支持c++11、c++14

2015-04-17

mingw_5.0.2.exe

mingw,window下的coding工具

2014-08-16

Linux内核设计与实现(LKD)_中文_第三版

linux内核入门书籍,《深入了解Linux内核》的导论,适合菜鸟.

2014-08-16

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除