- 博客(8)
- 收藏
- 关注
原创 PTA(A)1074 Reversing Linked List (25point(s))(坑)
思路:最后一个点是坑,可能存在孤立点。代码:#include <iostream>#include <algorithm>#include <vector>#include <cstdio>using namespace std;struct node { int address, next; int data;} mp[100005];vector<node>a;int main(){ in.
2020-06-01 23:58:52 680
原创 PTA(A)1067 Sort with Swap(0, i) (25point(s))
思路:找到一个不在位置上的数字,每次先通过0把一些数字归位,如果当前还没归位,就把9换到对应位置上。代码:#include <bits/stdc++.h>#include <cstdio>using namespace std;int pos[100005];int main(){ int n; cin >> n; for (int i = 0; i < n; ++i) { int num;.
2020-06-01 23:56:54 164
原创 PTA(A)1013 Battle Over Cities (25point(s))
思路:并查集建边,找孤立点,总数-2.代码: #include <bits/stdc++.h> using namespace std; #define M 1000005 #define N 1005 int f[N]; int a[M], b[M], k; int n, m; void init() { for (int i = 1; i <= n; ++i) .
2020-06-01 23:53:23 199
原创 PTA(A)1015 Reversible Primes (20point(s))
思路:判断原数字是不是质数,然后按照进制逆序后判断是不是质数。代码:#include <bits/stdc++.h>using namespace std;typedef long long ll;bool isPrime(ll x){ if (x == 1) return false; if (x == 2) return true; for (int i = 2; i <= sqrt(x); ++i) if (x % i =.
2020-06-01 23:50:35 151
原创 PTA(A)1019 General Palindromic Number (20point(s))
思路:变成对应的进制,然后判断是不是回文数。代码:#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n, b; cin >> n >> b; vector<ll>v; while (n) { v.push_back(n % b); n /= b; .
2020-06-01 23:47:50 142
原创 PTA(A)1137 Final Grading (25point(s))(模拟)
思路: 模拟即可。代码:#include <bits/stdc++.h>#include <cstdio>using namespace std;struct node { string name; int gp = -1; int gmid = -1; int gfinal = -1; int g = -1;};set<string>peo_name;map<string, node>peo_d.
2020-06-01 23:45:01 169
原创 PTA(A)1148 Werewolf - Simple Version (20point(s))(模拟)
思路: 遍历两个设为狼,然后根据发言,判断撒谎者。符合要求的就输出。代码:#include <bits/stdc++.h>#include <cstdio>using namespace std;int a[101];int main(){ int n; cin >> n; int f = 0; for (int i = 1; i <= n; ++i) { cin >> a[.
2020-06-01 23:42:53 319
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人