PAT
hbulzh
这个作者很懒,什么都没留下…
展开
-
PAT 家庭财产
做不动LCT,就来敲个模拟题解解气吧 dfs 存个结构体维护信息 排个序 然后没了 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 1e4+10, M = 1e6+10; int n, cnt; int h[N], tot; struct {int to,nxt;}e[M]; int houses[N], area[N],v原创 2020-10-19 15:41:40 · 93 阅读 · 0 评论 -
7-42 愿天下有情人都是失散多年的兄妹
个人认为这个题的测试数据有问题。 前边已经对sexs设置过初值,后边else语句不加过不了最后一个测试点,说明存在对一个人性别的反复修改。因为性别不同输出是不一样的。 ac代码: #include <bits/stdc++.h> using namespace std; const int N = 3e5+10; int h[N],tot,vis[N]; bool ...原创 2020-03-12 00:37:57 · 312 阅读 · 0 评论 -
1017 A除以B (20 分)
本题要求计算 A/B,其中 A 是不超过 1000 位的正整数,B 是 1 位正整数。你需要输出商数 Q 和余数 R,使得 A=B×Q+R 成立。 输入格式: 输入在一行中依次给出 A 和 B,中间以 1 空格分隔。 输出格式: 在一行中依次输出 Q 和 R,中间以 1 空格分隔。 输入样例: 123456789050987654321 7 输出样例: 17636684150141093474 3...原创 2019-02-25 15:58:16 · 94 阅读 · 0 评论 -
PAT 1003
单源最短路径的算法,存在 相等长度的路径,再做额外判断即可。 #include <bits/stdc++.h> #define MAX 1000000 using namespace std; int n,m,a,b; int G[501][501]; int resc[501]; int num = 1; int dis[501]; int visited[501] = {0};...原创 2019-03-12 09:43:40 · 88 阅读 · 0 评论 -
PAT 1004 Counting Leaves (30 分)
第一次 一边提交过,值得纪念一下 #include <bits/stdc++.h> #define N 105 using namespace std; vector<int> a[N]; int fa[N]; int n,m; int find_f(){ for(int i = 0; i < n; i++) if(fa[i+1] == i+1) retur...原创 2019-03-12 10:21:06 · 182 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25 分)
最大子列和问题,思路有很多种,深搜,dp都行,这里给出一种很俗的做法,快代码,慢代码,能过就是好代码 #include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; int a[N]; int main(){ int n; cin >> n; bool flag = false; fo...原创 2019-03-17 10:27:16 · 73 阅读 · 0 评论 -
1014 Waiting in Line (30 分)
该题细节特别多,注意如果轮到某人的话 #include <bits/stdc++.h> using namespace std; const int M = 1e3 + 10; int n,m,k,q,per; int cost[M]; int out[M],in[M]; queue<int> dl[21]; void Init(int k){ for(int ...原创 2019-03-21 11:47:42 · 134 阅读 · 0 评论 -
1010 Radix (25 分)
用二分法!用long long!! #include <bits/stdc++.h> using namespace std; typedef long long ll; ll jz(ll &rad, string &s){ ll t = 0; for(ll i = 0; i < s.size(); ++i){ if(isdig...原创 2019-03-19 13:42:22 · 104 阅读 · 0 评论