PAT
文章平均质量分 50
chan_yeol
这个作者很懒,什么都没留下…
展开
-
L3-1. 凑零钱 PAT团体设计天梯赛
题目 https://www.patest.cn/contests/gplt/L3-1#include#include#include#includeusing namespace std;int n,m,a[100000];int temp[100000];int tt=0,ttt=0;int dfs(int sum,int t,int re){ if(sum>m){原创 2016-05-10 12:40:06 · 767 阅读 · 0 评论 -
PAT 天梯赛初赛
L2-009. 抢红包#include#include#include#include#include#includeusing namespace std;int N;struct node{ int id; double money; int cnt; node(){ id=-1; money=0; cnt=0; }}person[10001];i原创 2016-06-07 19:55:39 · 1339 阅读 · 0 评论 -
L3-008. 喊山 天梯初赛
#include#include#include#include#includeusing namespace std;int N,M,K;vector G[10001];struct node{ int num; int level;};int vis[10001],pro[10001];int ans,level;int bfs(int num){ vis[num原创 2016-06-07 19:59:42 · 1145 阅读 · 0 评论 -
1082. Read Number in Chinese (25) PAT
注意细节,比如大小写,零的处理,以及空格#include#include#include#include#include#includeusing namespace std;mapm;mapmm;int pp=0;string solve(string str){ string tmp=""; if(str.length()==1&&str[0]=='0'){ r原创 2016-06-03 16:45:01 · 475 阅读 · 0 评论 -
1081. Rational Sum (20) PAT
#include #include #include #include #include #include using namespace std; int a[105]; //分子long long b[105]; //分母 long long gcd(long long a,long long b){ //最大公约数 return b==原创 2016-06-03 16:49:50 · 585 阅读 · 0 评论 -
1083. List Grades (25) PAT
简单题#include#include#include#include#include#includeusing namespace std;struct node{ string name; string id; int grade;}stu[100000];int N,a,b;int com(struct node a,struct node b){ retur原创 2016-06-03 17:12:33 · 418 阅读 · 0 评论 -
1076. Forwards on Weibo (30) PAT
简单题,随便搜一下就好了注意题目意思,M[i]是user_list [ i ]的粉丝#include#include#include#include#includeusing namespace std;vector user[1001];int N,L,ans;int vis[1001];struct node{ int id; int level;};voi原创 2016-06-03 19:23:13 · 491 阅读 · 0 评论 -
1078. Hashing (25) PAT
二次探测法,只考虑正增量。#include#include#include#includeusing namespace std;int Hash[10001];int Msize,N;int prime(int n){ int k=sqrt(n); int flag=0; if(n==0||n==1){ return 2; } if(n==2||n==3){原创 2016-06-03 20:32:43 · 490 阅读 · 0 评论 -
1079. Total Sales of Supply Chain (25)
#include#include#include#include#includeusing namespace std;int N;double M,r;int amount[100001];vector a[100001];double sale;void dfs(int n,double m){// cout<<m<<endl; if(a[n].size()==0){原创 2016-06-09 11:22:31 · 497 阅读 · 0 评论 -
PAT 1018. Public Bike Management (30)
#include#include#includeusing namespace std;int a[101][101],vis[101],dis[101];int bike[101],bike2[101],capacity[101],parent[101];int dij(int c,int n,int p){ vis[0]=1; bike[0]=0; for(int i=1;i原创 2016-12-01 20:06:51 · 408 阅读 · 0 评论 -
PAT 1010. Radix (25)
#include#include#includeusing namespace std;int get(char ch){ if(ch>='0'&&ch<='9'){ return ch-'0'; } else if(ch>='a'&&ch<='z'){ return ch-'a'+10; }}long long change(string str,long long原创 2016-12-01 20:08:51 · 382 阅读 · 0 评论 -
1080. Graduate Admission (30) PAT
看清题目的几点要求,没有难度#include#include#include#include#include#includeusing namespace std;mapm;//标记学生号码和排名,方便剪枝 int N,M,K;int quota[101];struct node{ int num; int Ge,Gi; double Gf; int rank;原创 2016-06-02 21:24:12 · 454 阅读 · 0 评论 -
1084. Broken Keyboard (20) PAT
不区分大小写,输出大写字母。#include#include#include#includeusing namespace std;mapm;int main(){ string str1,str2; char ch; cin>>str1>>str2; for(int i=0,j=0;i<str1.length();){ if(str1[i]>='a'&&str1[i]<=原创 2016-06-02 11:10:58 · 452 阅读 · 0 评论 -
L1-6. 连续因子 PAT团体程序设计天梯赛
题目 https://www.patest.cn/contests/gplt/L1-6#include#include#include#includeusing namespace std;long long a[1000000],length=0;long long n;long long bb,tt=1,pp[100000],ppp[100000];long long maxn原创 2016-05-10 12:42:29 · 690 阅读 · 0 评论 -
L2-1. 紧急救援 PAT
题目https://www.patest.cn/contests/gplt/L2-1#include#include#include#include#include#includeusing namespace std;struct node{ int nn; int pp; int step; int num; bool operator原创 2016-05-10 12:44:44 · 871 阅读 · 0 评论 -
L2-4. 这是二叉搜索树吗? PAT
题目 https://www.patest.cn/contests/gplt/L2-4#include#include#includeusing namespace std;int t[1005];int N;int tt[1005],flag;int pp[1005],temp;struct node{ int n; struct node*left; s原创 2016-05-10 12:46:30 · 1014 阅读 · 0 评论 -
1090. Highest Price in Supply Chain (25)
https://www.patest.cn/contests/pat-a-practise/1090#include#include#include#include#includeusing namespace std;int N,flag;double P,R;double maxn;vectorret[100001];struct node{ int num; do原创 2016-05-14 13:59:09 · 363 阅读 · 0 评论 -
L3-004. 肿瘤诊断 天梯赛模拟题
三维的bfs题目https://www.patest.cn/contests/gplt/L3-004#include#include#include#includeusing namespace std;int g[65][130][1300];int n,m,l,tt,ans;int dx[6]={0,0,-1,1,0,0};int dy[6]={0,0,0,0,1,-1原创 2016-05-16 17:16:15 · 1289 阅读 · 0 评论 -
1088. Rational Arithmetic (20)
PAT测试不支持%I64d 可以使用%lld,,被坑了好久。但是题目没有难度#include#include#include#includeusing namespace std;long long gcd(long long a,long long b){ if(a<0){ a=-a; } if(b<0){ b=-b; } long long t; if(a<b原创 2016-05-30 21:10:34 · 361 阅读 · 0 评论 -
1087. All Roads Lead to Rome (30) PAT
最短路径和dfs,先用dijkstra找出最短路径,然后用深搜找出相同路径的数量以及最佳答案;可以用map来标注city变量设的略乱,囧!#include#include#include#include#includeusing namespace std;int N,K;mapm;//标记城市名字mapmm;int G[205][205];int h[205],vis原创 2016-05-31 19:48:38 · 511 阅读 · 0 评论 -
团体程序设计天梯赛
L01-009 N个数求和#include#include#include#include#include#includeusing namespace std;int a[105];long long b[105];long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}long原创 2016-05-19 21:43:49 · 1041 阅读 · 0 评论 -
1085. Perfect Sequence (25) PAT
二分查找#include#include#include#include#includeusing namespace std;long long N,p;vector a;int main(){ int x; scanf("%d%d",&N,&p); for(int i=0;i<N;i++){ scanf("%d",&x); a.push_back(x); }原创 2016-06-01 18:10:16 · 518 阅读 · 0 评论 -
PAT 1119. Pre- and Post-order Traversals (30)
#include#include#include#includeusing namespace std;int n,pre[35],post[35],flag=0;int ans[35],k;struct node{ int num; struct node* left; struct node* right;};struct node* build(struct n原创 2016-12-01 20:10:26 · 590 阅读 · 0 评论