
PAT
Throneyjy
看星星咯
展开
-
1030 Travel Plan(纯暴力DFS,30分,没有用Dijkstra)
#include<iostream>#include<vector>using namespace std;const int inf=99999999;int N,M,S,D;int Cost[510][510];int Dis[510][510];vector<int> temppath,path;bool visit[510]={false};int mincost=inf;int mindis=inf;void dfs(int x,in.原创 2022-03-31 16:16:35 · 140 阅读 · 1 评论 -
1114 Family Property
#include<iostream>#include<algorithm>#include<vector>#include<unordered_set>using namespace std;struct node{ int totalnum; double totoalsets; double totoalarea; double avgarea; double avgset;}family[10000];bool visited.原创 2021-12-21 15:44:10 · 108 阅读 · 0 评论 -
1028 List Sorting
#include<iostream>#include<string>#include<algorithm> using namespace std;struct student{ string ID; string name; int grade;}stu[100001];bool cmp1(student a,student b){ return a.ID<b.ID;}bool cmp2(student a,student b){ i.原创 2021-12-13 10:38:35 · 522 阅读 · 0 评论 -
1116 Come on Let‘s C
#include<iostream>#include<vector>using namespace std; bool isPrime(int x){ if(x==1) return false; for(int i=2;i*i<=x;i++) if(x%i==0) return false; return true;}struct node{ string ID; string reward; bool isvisit=false;}N.原创 2021-12-11 15:23:09 · 107 阅读 · 0 评论 -
1136 A Delayed Palindrome
采用大整数加法计算。#include<bits/stdc++.h>using namespace std;string s;void add(string x){ int flag=0; for(int i=x.length()-1;i>=0;i--){ int temp=s[i]-'0'+x[i]-'0'+flag; flag=0; if(temp>9){ temp=temp-10; flag=1; } s[i]=temp+'0';原创 2021-12-11 10:54:32 · 239 阅读 · 0 评论 -
Palindromic Number
代码参考了链接:PAT甲级 1024. Palindromic Number (25) 大整数相加(利用字符串模拟整数相加)_love music.的博客-优快云博客其中对于大整数加饭,add模板是通用的,实现两个超过long long范围整数的加法。注意single number也是满足要求的#include<iostream>#include<algorithm> using namespace std; string s;void add(st转载 2021-12-09 20:28:43 · 236 阅读 · 0 评论 -
1023 Have Fun with Numbers
使用map<char,int>来记录不同char类型数字出现的次数,成立条件为map1==map2(各种数字出现的个数相等)用string类型处理字符串,唯一需要注意的是对string做double处理后可能需要进位#include<iostream>#include<string>#include<map>using namespace std;map<char,int> mp1,mp2;string Double(strin原创 2021-12-08 20:32:42 · 515 阅读 · 0 评论 -
Group Photo(PAT)
#include<iostream>#include<algorithm>#include<cstring>#include<vector>using namespace std;struct node{ string name; int height;};vector<node> v;bool cmp(node a, node b){ if(a.height!=b.height) return a.height&...原创 2021-12-06 17:53:26 · 259 阅读 · 0 评论 -
Hello world for U
#include<iostream>#include<cstring>#include<cmath>using namespace std;int main(){ string str; cin>>str; int n=str.length()+2; int n1=n/3; int n2=n-2*n1; int k=n2-2;//to record the spaceplace's number...原创 2021-12-06 16:10:36 · 531 阅读 · 0 评论