PAT 1139 First Contact[难][模拟]】的更多相关文章

1139 First Contact(30 分) Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instea…
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask another b…
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805344776077312 题意: 有m对朋友关系,每个人用4为数字的编号表示,如果是负数表示这是女生. 给定k个查询,对于要查的人a和b,问有多少对朋友(c,d)使得c和a是同性,d和b是同性,且c和d是朋友. 思路: 枚举a的所有同性朋友,枚举b的所有同性朋友,看他们是不是朋友. 首先用了map离散化了一下给了个id,可能是这里搞来搞去T了最后一组数据. 实际…
原题链接: https://pintia.cn/problem-sets/994805342720868352/problems/994805344776077312 测试点分析: 首先来分析一下测试点,这样可以站在命题者的角度来分析问题. 测试点 分值 数据特点 0 18 主测试点,10<=n<70,没有刁难性的数据,数据量一般,ID从0001到3000即可通过,测试基本功能. 1 4 n=7,存在+0000数据,但不存在-0000数据,ID从0000到5000. 2 2 n=7,存在-00…
题目链接 解法暴力 因为有 0000, -0000 这样的数据,所以用字符串处理 同性的时候,遍历好朋友时会直接遍历到对方,这个时候应该continue #include<cstdio> #include<iostream> #include<cstring> #include<string> #include<vector> #include<algorithm> #include<unordered_map> #inc…
1085 Perfect Sequence (25 分) Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respectively. Now given a seq…
由于本人愚笨,最后一题实在无力AC,于是只有前14题的题解Orz 总的来说,这次模拟赛的题目不算难,前14题基本上一眼就有思路,但是某些题写起来确实不太容易,编码复杂度有点高~ L1-1 N个数求和 设计一个分数类,重载加法运算符,注意要约分,用欧几里得算法求个最大公约数即可. #include <cstdio> long long abs(long long x) { ? -x : x; } long long gcd(long long a, long long b) { ) return…
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask another b…
1103 Integer Factorization(30 分) The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P factorization of N for any positive integers N, K an…
1042 Shuffling Machine (20)(20 分) Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by perfor…