PAT甲级
李不予
这个作者很懒,什么都没留下…
展开
-
1148 Werewolf - Simple Version
狼人游戏,有两个狼人,有一个狼人和一个平民说谎。方法:枚举原创 2018-11-06 20:49:01 · 153 阅读 · 0 评论 -
PAT甲级 1002 A+B for Polynomials
#include<iostream>using namespace std;double num[1001]={0.0};int main(){ int N,exp,cnt=0; double coe; scanf("%d",&N); for(int i=0;i<N;i++){ scanf("%d%lf",&exp,&coe); nu...原创 2019-04-04 17:28:29 · 165 阅读 · 0 评论 -
1155 Heap Paths
#include<iostream>#include<vector>using namespace std;int N;vector<int> ori;vector<int> ans;void dfs(int v){ if(v>N) return; ans.push_back(ori[v]); if(v*2>N&...原创 2019-03-02 12:42:55 · 180 阅读 · 0 评论 -
1138 Postorder Traversal
#include<iostream>#include<vector>using namespace std;vector<int> pre,in,post;void postOrder(int preL,int inL,int inR){ if(inL>inR) return; int i=inL; while(i<=inR&&...原创 2018-12-05 21:53:20 · 125 阅读 · 0 评论 -
1102 Invert a Binary Tree
将现有二叉树的左子树和右子树交换输出新的二叉树的层序和中序原创 2018-12-08 21:28:47 · 139 阅读 · 0 评论 -
1151 LCA in a Binary Tree
#include#include#includeusing namespace std;vector pre,in;map&lt;int,int&gt; pos;void lca(int U,int V,int preRoot,int inL,int inR){if(inL&gt;inR) return;int posU=pos[U],posV=pos[V],posRoot=pos...原创 2018-12-03 16:37:05 · 97 阅读 · 0 评论 -
1146 Topological Order
拓扑排序原创 2018-12-08 18:31:40 · 155 阅读 · 0 评论 -
1145 Hashing - Average Search Time
#include<iostream>#include<vector>#include<cmath>using namespace std;bool isP(int n){ if(n<=1) return false; for(int i=2;i<=sqrt(n);i++){ if(n%i==0) return false; } r...原创 2018-12-08 16:29:25 · 127 阅读 · 0 评论 -
1144 The Missing Number
#include<iostream>#include<map>using namespace std;map<int,bool> exist;int main(){ int n,num,cnt=1; cin>>n; for(int i=0;i<n;i++){ cin>>num; if(num>0) ...原创 2018-12-08 14:17:14 · 102 阅读 · 0 评论 -
1150 Travelling Salesman Problem
#include<iostream>#include<set>#include<algorithm>#include<vector>using namespace std;int e[210][210];const int inf=100000000;int main(){ int N,M,K,n,w,a,b; cin>>...原创 2018-11-15 12:57:45 · 319 阅读 · 0 评论 -
1149 Dangerous Goods Packaging
告诉你某些物品时不能放在一起的,然后在给你一些物品,问它们能不能打包在一起。原创 2018-11-06 21:08:40 · 128 阅读 · 0 评论 -
PAT甲级目录
更新中原创 2018-11-06 20:53:50 · 157 阅读 · 0 评论 -
PAT甲级 1001 A+B Format
#include<stdio.h>int main(){ int a,b,c,num[7],len=0; scanf("%d%d",&a,&b); c=a+b; if(c<0){ printf("-"); c=-c; } do{ num[len++]=c%10; c/=10; }while(c!=0);//C=199999 for...原创 2019-04-04 17:34:06 · 89 阅读 · 0 评论