自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(118)
  • 收藏
  • 关注

原创 Python开发环境搭建

由于Python支持跨平台,所以自己在win7,centos里都安装试了试,终于成功啦Windows系统:     直接官网下载Python最新版本,又下载一个Geany文本编辑器就齐活啦,比较简单linux系统:   在书上看说有对应的deadsnakes包,但最终不能用,因为这个包是Ubuntu里的     正确安装步骤:su - 进入root模式编译需要的一些包yum -y groupins...

2018-05-02 23:59:37 227

原创 A1068 Find More Coins

#include<cstdio> #include<algorithm> using namespace std; const int maxn=10010; const int maxv=110; int w[maxn],dp[maxv]={0}; bool choice[maxn][maxv],flag[maxn]; bool cmp(int a,int b) { r...

2018-03-14 10:28:47 210

原创 A1040 Longest Symmetric String

#include<cstdio> #include<cstring> const int maxn=1010; char S[maxn]; int dp[maxn][maxn]; int main() { gets(S); int len=strlen(S),ans=1; memset(dp,0,sizeof(dp)); for(int i=0;i<len;...

2018-03-14 10:08:54 186

原创 A1045 Favorite Color Stripe

#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxc=210; const int maxn=10010; int HashTable[maxc]; int A[maxn],dp[maxn]; int main() { int n,...

2018-03-14 09:48:06 193

原创 A1007 Maximum Subsequence Sum

#include<cstdio> const int maxn=10010; int a[maxn],dp[maxn]; int s[maxn]={0}; int main() { int n; scanf("%d",&n); bool flag=false; for(int i=0;i<n;i++) { scanf("%d",&a[i]); ...

2018-03-14 09:35:28 187

原创 A1087 All Roads Lead to Rome

#include<iostream> #include<cstdio> #include<cstring> #include<map> #include<string> #include<algorithm> using namespace std; const int MAXV=210; const int INF=1000...

2018-03-14 09:15:34 321

原创 A1030 Travel Plan

#include<cstdio> #include<cstring> #include<vector> #include<algorithm> using namespace std; const int maxv=510; const int INF=1000000000; int n,m,st,ed,G[maxv][maxv],cost[max...

2018-03-14 07:48:01 295

原创 A1003 Emergency

#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxv=510; const int INF=1000000000; int n,m,st,ed,G[maxv][maxv],weight[maxv]; int d[maxv],w[maxv...

2018-03-14 00:41:27 178

原创 A1076 Forwards on Weibo

#include<cstdio> #include<cstring> #include<vector> #include<queue> using namespace std; const int maxv=1010; struct Node { int id; int layer; }; vector<Node> adj[maxv]...

2018-03-14 00:08:16 191

原创 A1034 Head of aGang

#include<iostream> #include<string> #include<map> using namespace std; const int maxn=2010; map<int,string> intToString; map<string,int> stringToInt; map<string,int&g...

2018-03-13 23:31:16 161

原创 A1021 Deepest Root

#include<cstdio> #include<vector> #include<algorithm> using namespace std; const int N=100010; vector<int> G[N]; bool isRoot[N]; int father[N]; int findFather(int x) { int a=...

2018-03-13 22:46:18 186

原创 A1013 Battle over cities

对于一个无向图,求删除一个顶点编号后需要增加多少条边,才能使图变为连通#include<cstdio> #include<cstring> #include<vector> using namespace std; const int N=1111; vector<int> G[N]; bool vis[N]; int currentPoint; ...

2018-03-13 20:53:30 155

原创 A1107 Social Clusters

#include<cstdio> #include<algorithm> using namespace std; const int N=1010; int father[N]; int isRoot[N]={0}; int course[N]={0}; int findFather(int x) { int a=x; while(x!=father[x]) { ...

2018-03-13 17:53:30 124

原创 A1099 Build a Binary Search Tree

#include<cstdio> #include<queue> #include<algorithm> using namespace std; const int maxn=110; struct node { int data; int lchild,rchild; }Node[maxn]; int n,origin[maxn],num=0; void...

2018-03-13 15:08:50 133

原创 A1064 Complete Binary Search Tree

二叉排序树+完全二叉树,用数组存放完全二叉树,中序遍历元素#include<cstdio> #include<algorithm> using namespace std; const int maxn=1010; int n,number[maxn],CBT[maxn],index=0; void inorder(int root) { if(root>n) r...

2018-03-13 14:08:50 145

原创 A1043 Is it a Binary Search Tree

note:对镜像树的先序遍历只需要在原树的先序遍历时交换左右子树的访问顺序即可#include<cstdio> #include<vector> using namespace std; struct node { int data; node *left,*right; }; void insert(node* &root,int data) { if(r...

2018-03-13 11:00:03 114

原创 A1053 Path of Equal Weight

强调:在读入时对每个结点的所有子结点按权值从大到小排序,这样在递归的过程中总是会先访问所有子结点中权值更大的#include<cstdio> #include<vector> #include<algorithm> using namespace std; const int maxn=110; struct node { int weight; vecto...

2018-03-13 10:09:49 225 1

原创 A1104 Counting Leaves

给出一棵树,问每一层各有多少叶子结点#include<cstdio> #include<vector> #include<cmath> using namespace std; const int maxn=110; vector<int> G[maxn]; int leaf[maxn]={0}; int maxh=1; void DFS(int ...

2018-03-13 08:55:58 136

原创 A1106 Lowest Price in Supply Chain

#include<cstdio> #include<vector> #include<cmath> using namespace std; const int maxn=100010; const int INF=1000000000; ///**** vector<int> Node[maxn]; int n; double p,r; int n...

2018-03-13 08:16:23 142

原创 A1094 The Largest Generation

#include<cstdio> #include<vector> using namespace std; const int maxn=110; vector<int> Node[maxn]; int hashtable[maxn]={0}; void DFS(int index,int level) { hashtable[level]++; for...

2018-03-13 07:47:59 147

原创 A1090 Hightest Price in Supply Chain

#include<cstdio> #include<vector> #include<cmath> using namespace std; const int maxn=100010; vector<int> child[maxn]; double p,r; int n,maxdepth=0,num=0; void DFS(int index,i...

2018-03-13 07:03:26 123

原创 A1079 Total State of Supply Chain

又回来了,忙了几天别的考试,发现不知不觉又一个星期未敲代码,这可不算好的程序员干的事,敲起来,快考试啦#include<cstdio> #include<cmath> #include<vector> using namespace std; const int maxn=100010; struct node { double data; vector&...

2018-03-12 21:38:28 183

原创 A1086 Tree Traversals Again

#include<cstdio> #include<cstring> #include<stack> #include<algorithm> using namespace std; const int maxn=50; struct node { int data; node* lchild; node* rchild; }; int pr...

2018-03-05 22:49:17 131

原创 A1020 Tree Traversals

#include<cstdio> #include<cstring> #include<queue> #include<algorithm> using namespace std; const int maxn=50; struct node { int data; node* lchild; node* rchild; }; int pre...

2018-03-05 22:16:47 158

原创 A1103 Integer Factorization

#include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; int n,k,p,maxFacSum=-1; vector<int> fac,temp,ans; void init() { int i=1; do...

2018-03-05 20:45:57 268

原创 A1052 Linked List Sorting

#include<cstdio> #include <algorithm> using namespace std; struct NODE { int address, key, next; bool flag; }node[100000]; int cmp1(NODE a, NODE b) { return !a.flag || !b.flag ...

2018-03-05 17:29:37 143

原创 A1032 Sharing

#include<cstdio> #include<algorithm> using namespace std; int main() { int first1,first2,n; scanf("%d%d%d",&first1,&first2,&n); char data[100010]; int next[100010]; int li...

2018-03-05 16:13:28 130

原创 B1025/A1074 反转链表

#include <iostream> #include<cstdio> #include <algorithm> using namespace std; int main() { int first,n,k,temp; scanf("%d%d%d",&first,&n,&k); int data[100010...

2018-03-05 14:51:30 186

原创 A1056 Mice and Rice

注:如果当前剩下的老鼠可以分为group组,那么这一组里面没有晋级的老鼠排名就是group+1#include <iostream> #include<cstdio> #include <queue> #include <vector> #include <algorithm> using namespace std; struct no...

2018-03-05 14:16:25 175

原创 A1051 Pop Sequence

#include<cstdio> #include<stack> #include<vector> using namespace std; int main() { int m,n,k; scanf("%d%d%d",&m,&n,&k); vector<int> v(n+2); stack&lt

2018-03-05 11:18:54 109

原创 A1054 The Dominant Color

#include<cstdio> #include<map> using namespace std; int main() { int m,n,col; map<int,int> count; scanf("%d%d",&m,&n); for(int i=0;i<n;i++) { for(int j=0;j<m;j++...

2018-03-05 00:30:26 145

原创 B1044 火星数字

#include <iostream> #include<cstdio> #include <string> using namespace std; void func1(string s); void func2(string s); int main() { int n; scanf("%d",&n); getchar...

2018-03-04 23:42:53 258

原创 A1063 Set Similarity

#include<cstdio> #include<set> using namespace std; const int N=51; set<int> st[N]; void compare(int x,int y)///x,y均为int型!!! { int totalnum=st[y].size(); int samenum=0; for(set&lt...

2018-03-04 22:26:16 114

原创 A1047 Student List for Course

#include<cstdio> #include<vector> #include<algorithm> using namespace std; const int maxn=400010; const int maxc=2510; char name[maxn][5];///***定义二维数组存储姓名 vector<int> v[maxc]...

2018-03-04 21:19:02 133

原创 A1039 Course List for Student

思路:用hash将学生姓名转换为int,然后存到vector数组中#include<cstdio> #include<vector> #include<algorithm> using namespace std; const int maxn=26*26*26*10+1; vector<int> v[maxn]; ////*****注意写法,这样...

2018-03-04 20:44:28 230

原创 A1024 Palindromic Number

#include<iostream> #include<string> #include<algorithm> using namespace std; string s; void add(string t) { int len=s.length(),carry=0; for(int i=0;i<len;i++)///两个字符串从高位相加,最后逆转,...

2018-03-04 19:54:39 198

原创 A1023 Have Fun with Numbers

字符串乘法#include <cstdio> #include <string.h> using namespace std; int book[10]={0};//标记每一数位 int main() { char num[22]; scanf("%s", num); int flag = 0, len = strlen(num); for...

2018-03-04 17:51:36 126

原创 B1017 A除以B

思路:模拟手动除法过程,每一位够除的写到最终商的结果中,余数*10加后一位的值继续进行除法操作。#include <iostream> #include<string> using namespace std; int main() { string s; int a, t = 0, temp = 0; cin >> s >>...

2018-03-04 17:30:25 370

原创 A1059 Prime Factors

注:N不会被除自己以外的大于sqrt(N)的整数整除#include<cstdio> #include<cmath> const int maxn=100010; bool isprime(int n) { if(n<=1) return false; int sqr=(int)sqrt(1.0*n); for(int i=2;i<sqr;i++) { ...

2018-03-04 17:08:22 176

原创 A1078 Hashing

结论:如果步长step从0~TSize-1进行枚举仍然无法找到正确位置,那么对step大于等于TSize来说也不可能找到位置注:数组定义时给的大小不能是变量,必须是常量,否则报错:[Error] F:\PAT\C-Free Standard\temp\未命名7.cpp:22: variable-sized object `hash' may not be initialized#include&l...

2018-03-04 15:28:02 377

空空如也

空空如也

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

TA关注的人

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