PAT(甲级)
文章平均质量分 88
L_Aster
..
展开
-
1046. Shortest Distance (20)
1046. Shortest Distance (20)#include <bits/stdc++.h>using namespace std;int main(){ int n,sum=0,x,k; scanf("%d",&n); vector<int> val(n+1,0); for(int i=1;i<=n;...原创 2016-09-09 19:40:19 · 277 阅读 · 0 评论 -
1054. The Dominant Color (20)
题目:1054. The Dominant Color (20)#include<stdio.h>#define d 4096struct store{ int a[d];}s[d];int main(){ int i,j,m,n; scanf("%d %d",&m,&n); for(i=0;i<n;i++) { for(j=0;j原创 2016-09-10 11:47:32 · 264 阅读 · 0 评论 -
1050. String Subtraction (20)
题目:1050. String Subtraction (20)#include<stdio.h>#include<string.h>#define N 10005int main(){ char s[N],ch; int a[300]={0},i=0,n; gets(s); n=strlen(s); while((ch=getchar())!='\n原创 2016-09-10 11:50:17 · 287 阅读 · 0 评论 -
1058. A+B in Hogwarts (20)
题目:1058. A+B in Hogwarts (20)#include<stdio.h>int main(){ int G,S,K; int aG,aS,aK,bG,bS,bK; int addS=0,addG=0; scanf("%d.%d.%d %d.%d.%d",&aG,&aS,&aK,&bG,&bS,&bK); K=aK+bK; add原创 2016-09-10 12:01:16 · 415 阅读 · 0 评论 -
1065. A+B and C (64bit) (20)
题目:1065. A+B and C (64bit) (20)#include<stdio.h>int main(){ long long a,b,c; int n,i,tag=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%lld %lld %lld",&a,&b,&c); lo原创 2016-09-10 16:28:50 · 356 阅读 · 0 评论 -
1003. Emergency (25)
题目:1003. Emergency (25)#include<stdio.h>#define MAX 500#define Inf 99999999int main(){ int vernum,arcnum,v1,v2; int a[MAX][MAX],rescue[MAX],key[MAX],dist[MAX]; int selectnum[MAX],maxres原创 2016-09-24 13:34:26 · 471 阅读 · 0 评论 -
1051. Pop Sequence (25)
1051. Pop Sequence (25)#include <stdio.h>int main(){ int stack[1000],top; int m,n,k; scanf("%d %d %d",&m,&n,&k); while(k--) { int v=1,i,e; top=0; for(i=0;i原创 2016-11-05 14:32:22 · 346 阅读 · 0 评论 -
1055. The World's Richest (25)
1055. The World’s Richest (25)#include <stdio.h>#include <stdlib.h>#include <string.h>struct record{ char name[10]; int age; int worth;}s[100001];int comp(const void*a,const void*b){原创 2016-11-06 10:45:38 · 378 阅读 · 0 评论 -
1025. PAT Ranking (25)
题目:1025. PAT Ranking (25)#include <stdio.h>#include <stdlib.h>#include <string.h>struct record{ char renumber[16]; int finalrank; int localnum; int localrank; int score;}s[3000原创 2016-10-30 22:34:51 · 342 阅读 · 0 评论 -
1028. List Sorting (25)
题目:1028. List Sorting (25)#include <stdio.h>#include <stdlib.h>#include <string.h>struct record{ int num; char name[10]; int score;}s[100001];int comp1(const void*a,const void*b){原创 2016-10-30 22:52:17 · 366 阅读 · 0 评论 -
1084. Broken Keyboard (20)
1084. Broken Keyboard (20) 乙级的题目:链接原创 2016-11-12 17:06:13 · 293 阅读 · 0 评论 -
1092. To Buy or Not to Buy (20)
1092. To Buy or Not to Buy (20) 乙级的题:链接原创 2016-11-12 17:10:09 · 300 阅读 · 0 评论 -
1037. Magic Coupon (25)
题目:1037. Magic Coupon (25)#include <iostream>#include <algorithm>#include <vector>using namespace std;int comp(int a,int b){ return a>b;}int comn(int a,int b){ return a<b;}int main()原创 2016-11-01 21:17:38 · 349 阅读 · 0 评论 -
1097. Deduplication on a Linked List (25)
1097. Deduplication on a Linked List (25)#include <stdio.h>#include <stdlib.h>struct node{ int address; int data; int next;}node[100001];struct node *aqueue[100001],*bqueue[100001];in原创 2016-11-29 21:52:18 · 345 阅读 · 0 评论 -
1096. Consecutive Factors (20)
1096. Consecutive Factors (20)#include <stdio.h>#include <math.h>int main(){ int n; scanf("%d",&n); int key=sqrt((double)n); int s,maxlen=0; for(int i=2;i<=key;++i) {原创 2016-11-14 15:33:41 · 364 阅读 · 0 评论 -
1093. Count PAT's (25)
1093. Count PAT’s (25)#include<stdio.h>#include<string.h>#define N 100005int main(){ long long count=0; int i=0,k=0,p=0,t=0,b[N],a[N],n; char s[N],ch; while((ch=getchar())!='\n')原创 2016-11-14 16:04:27 · 297 阅读 · 0 评论 -
1104. Sum of Number Segments (20)
1104. Sum of Number Segments (20) 乙级:1049. 数列的片段和(20)原创 2016-11-14 16:09:39 · 352 阅读 · 0 评论 -
1090. Highest Price in Supply Chain (25)
1090. Highest Price in Supply Chain (25)#include <cstdio>#include <vector>#include <cmath>int maxheight=-1,find=0;void dfs(int k,int h,std::vector<std::vector<int>> &v){ if(maxheight<h) {原创 2016-11-29 23:14:04 · 270 阅读 · 0 评论 -
1074. Reversing Linked List (25)
1074. Reversing Linked List (25)#include <stdio.h>struct node{ int address; int data; int next;}node[100001];struct node *stack[100001];struct node *queue[100001];int top,front,rear;i原创 2016-11-29 23:44:16 · 328 阅读 · 0 评论 -
1067. Sort with Swap(0,*) (25)
1067. Sort with Swap(0,*) (25)#include <stdio.h>#define N 100000+1void swap(int*a,int*b){ int temp=*a; *a=*b;*b=temp;}int FindPosition(int a[],int n,int s){ int i; for(i=s;i<n;++i原创 2016-11-17 20:28:02 · 328 阅读 · 0 评论 -
1062. Talent and Virtue (25)
1062. Talent and Virtue (25) 乙级:1015. 德才论 (25)原创 2016-11-15 14:49:34 · 342 阅读 · 0 评论 -
1120. Friend Numbers (20)
1120. Friend Numbers (20) 乙级:1064. 朋友数(20)原创 2016-12-11 18:17:00 · 298 阅读 · 0 评论 -
1018. Public Bike Management (30)
1018. Public Bike Management (30) 思路:用dijkstra算法求出并用path记录多条路径,然后dfs筛选最优路径 注意:send和back的记录;在沿途中,如果count<0的话,说明需要send,比如0->4,4,7,从原点出发,经过4,为使其perfect,需要send,最终结果为,send=2,back=2(并不是send和back中一定有一个为0)#i原创 2016-11-20 13:41:54 · 964 阅读 · 0 评论 -
1087. All Roads Lead to Rome (30)
1087. All Roads Lead to Rome (30) dijkstra+dfs#include <iostream>#include <vector>#include <algorithm>#include <unordered_map>#define Inf 9999999using namespace std;ve...原创 2016-12-02 23:40:24 · 453 阅读 · 0 评论 -
1030. Travel Plan (30)
1030. Travel Plan (30) dijkstra记录所有最短路径,dfs筛选最优路径即可#include <cstdio>#include <vector>#define N 500+1#define INF 999999999std::vector<std::vector<int>> path(N);std::vector<int> sp;std::vector<int原创 2016-12-03 09:53:03 · 283 阅读 · 0 评论 -
1123. Is It a Complete AVL Tree (30)
1123. Is It a Complete AVL Tree (30)#include <bits/stdc++.h>using namespace std;struct TreeNode{ int val; TreeNode *left,*right; TreeNode(int v):val(v),left(NULL),right(NULL){...原创 2016-12-13 08:49:37 · 406 阅读 · 0 评论 -
1022. Digital Library (30)
1022. Digital Library (30)#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 80+1struct book{ char id[8]; char title[N]; char author[N]; char keywords[100]; char原创 2016-11-25 19:43:38 · 295 阅读 · 0 评论 -
1057. Stack (30)
1057. Stack (30) 思路:桶 注意,可能存在一样的key值(最后两个测试点),记录和查询中位数时要注意处理。#include <stdio.h>int table[320][320];int count[320];int stack[320*320],top=0;void push(int e){ stack[top++]=e; table[e/320][e原创 2016-12-09 20:00:11 · 339 阅读 · 0 评论 -
1017. Queueing at Bank (25)
题目:1017. Queueing at Bank (25)#include <stdio.h>#include <stdlib.h>#define N 10001struct record{ int stime; int etime;}s[N];int service[101];int comp(const void*a,const void*b);int comp原创 2016-10-25 19:33:21 · 573 阅读 · 0 评论 -
1075. PAT Judge (25)
1075. PAT Judge (25)#include <stdio.h>#include <stdlib.h>struct record{ int thisid; int grade[5+1]; int sumscores; int countperfect; int islist; int rank;}s[10000+1];int co原创 2016-12-10 09:54:24 · 292 阅读 · 0 评论 -
1110. Complete Binary Tree (25)
1110. Complete Binary Tree (25)#include <stdio.h>#include <stdlib.h>struct tree{ int left; int right;}node[21];int findroot[21];int TransFuction(char s[]){ return (s[0]=='-')?-1:atoi原创 2016-12-21 15:38:02 · 308 阅读 · 0 评论 -
1108. Finding Average (20)
1108. Finding Average (20) 1054. 求平均值 (20)原创 2016-12-19 15:53:34 · 381 阅读 · 0 评论 -
1089. Insert or Merge (25)
1089. Insert or Merge (25) 注:存在等值数据#include <stdio.h>#include <stdlib.h>int n,b[101],a[101];int comp(const void*a,const void*b){ return *((int*)a)-*((int*)b);}int juge(int s,int e){ if(原创 2017-01-04 21:41:30 · 379 阅读 · 0 评论 -
1098. Insertion or Heap Sort (25)
1098. Insertion or Heap Sort (25)#include <stdio.h>int heap[101]={200};int a[101],b[101];void HeapAdjust(int heap[],int s,int e){ int temp=heap[s]; int parent=s,child; while(2*parent<=e原创 2017-01-07 11:21:23 · 283 阅读 · 0 评论 -
1049. Counting Ones (30)
1049. Counting Ones (30) 思路:计算每个‘位’上为1的组合个数,再进行求和#include <iostream>#include <cmath>#include <cstdlib>#include <string>using namespace std;int main(){ string n; cin>>n; int ans=0;原创 2017-02-04 14:56:32 · 320 阅读 · 0 评论 -
1045. Favorite Color Stripe (30)
1045. Favorite Color Stripe (30)#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;int color[202],dp[202];int main(){ int n,m,len; cin>>n>>m;原创 2017-02-04 16:16:09 · 226 阅读 · 0 评论 -
1068. Find More Coins (30)
1068. Find More Coins (30)#include <iostream>#include <vector>#include <algorithm>using namespace std;const int MAXN=10004,MAXM=104;int n,m;int v[MAXN],dp[MAXN][MAXM];bool flag[MAXN][MAXM];int原创 2017-02-04 19:38:46 · 303 阅读 · 0 评论 -
1038. Recover the Smallest Number (30)
1038. Recover the Smallest Number (30)#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;bool comp(const string &a,const string &b){ return a+b<b+a;原创 2017-02-04 11:39:46 · 252 阅读 · 0 评论 -
1072. Gas Station (30)
1072. Gas Station (30) Dijkstra算法求所有居住点到候选gas staion的最短距离,如果其中最短距离大于ds则超出范围;注意题目中gas点和居住点的区别,本代码将gas点放于1000后#include <iostream>#include <vector>#include <cstdio>#include <algorithm>using namespace原创 2017-02-05 12:11:09 · 295 阅读 · 0 评论 -
1080. Graduate Admission (30)
1080. Graduate Admission (30) 考察排序#include <iostream>#include <vector>#include <algorithm>using namespace std;struct node{ int id; double ge; double gi; double gf; vector<int>原创 2017-02-06 14:14:18 · 238 阅读 · 0 评论