PAT-2018年冬季考试-乙级
代码:
#include <bits/stdc++.h>
using namespace std; int T; int A(int a) {
int cnt = ;
while(a) {
a /= ;
cnt ++;
}
return cnt;
} int Pow(int a, int b) {
int ans = ;
for(int i = ; i <= b; i ++)
ans *= a;
return ans;
} int main() {
scanf("%d", &T);
while(T --) {
int x;
scanf("%d", &x);
int c = A(x);
int sum = x * x;
int temp = , out = ;
for(int i = ; i <= ; i ++) {
if((sum * i) % Pow(, c) == x) {
temp = i;
out = sum * i;
break;
}
}
if(temp == )
printf("No\n");
else {
printf("%d %d\n", temp, out);
}
}
return ;
}
代码:
#include <bits/stdc++.h>
using namespace std; int N, M; struct Node{
int kind;
int price;
int sum;
}node[]; bool cmp(const Node& a, const Node& b) {
if(a.sum != b.sum)
return a.sum > b.sum;
else return a.kind < b.kind;
} int main() {
scanf("%d%d", &N, &M);
for(int i = ; i < M; i ++) {
for(int j = ; j <= N; j ++) {
int x;
scanf("%d", &x);
node[j].kind = j;
node[j].sum += x;
}
}
int cnt = ;
sort(node + , node + N + , cmp);
printf("%d\n", node[].sum);
for(int i = ; i <= N; i ++) {
if(node[i].sum == node[].sum)
cnt ++;
} for(int i = ; i <= cnt; i ++) {
printf("%d", node[i].kind);
printf("%s", i != cnt ? " " : "\n");
}
return ;
}
代码:
#include <bits/stdc++.h>
using namespace std; string A, B; int main() {
getline(cin, A);
getline(cin, B);
int la = A.length(), lb = B.length();
map<char, int> mp;
for(int i = ; i < la; i ++) {
if(mp[A[i]] == ) {
printf("%c", A[i]);
mp[A[i]] ++;
}
}
for(int i = ; i < lb; i ++) {
if(mp[B[i]] == ) {
printf("%c", B[i]);
mp[B[i]] ++;
}
}
printf("\n");
return ;
}
代码:
#include <bits/stdc++.h>
using namespace std; char s[];
int K, len; bool isPrime(int x) {
if(x == || x == ) return false;
if(x == ) return true;
for(int i = ; i * i <= x; i ++)
if((x % i) == ) return false;
return true;
} int main() {
scanf("%d%d", &len, &K);
scanf("%s", s);
int ans;
bool flag = false;
vector<int> out;
for(int i = ; i <= len - K; i ++) {
ans = ;
out.clear();
for(int j = i; j < i + K; j ++) {
ans = ans * + s[j] - '';
out.push_back((s[j] - ''));
}
if(isPrime(ans)) {
flag = true;
break;
}
}
if(flag) {
for(int i = ; i < K; i ++)
printf("%d", out[i]);
}
if(!flag)
printf("404\n");
return ;
}
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ; struct Node{
char id[];
int score;
}node[maxn], s1[maxn], s2[maxn]; Node asd; struct N3{
int room;
int ren;
}num[maxn], endd[maxn]; bool cmpp(const N3& a, const N3& b) {
if(a.ren != b.ren)
return a.ren > b.ren;
else return a.room < b.room;
} bool cmp1(const Node& a, const Node& b) {
if(a.score != b.score)
return a.score > b.score;
else return strcmp(a.id, b.id) < ;
} int main() {
int N, M;
scanf("%d%d", &N, &M);
int zlr = ;
for(int i = ; i <= N; i ++) {
scanf("%s%d", asd.id, &asd.score);
if(asd.score >= && asd.score <= ) {
zlr ++;
node[zlr].score = asd.score;
strcpy(node[zlr].id, asd.id);
}
} for(int t = ; t <= M; t ++) {
int x;
char op[];
scanf("%d %s", &x, op);
if(x == ) {
int cnt1 = ;
for(int i = ; i <= zlr; i ++) {
if(node[i].id[] == op[]) {
cnt1 ++;
strcpy(s1[cnt1].id, node[i].id);
s1[cnt1].score = node[i].score;
}
}
printf("Case %d: %d %s\n", t, x, op);
if(cnt1 == )
printf("NA\n");
else {
sort(s1 + , s1 + + cnt1, cmp1);
for(int i = ; i <= cnt1; i ++)
printf("%s %d\n", s1[i].id, s1[i].score);
}
} else if(x == ) {
int lx = strlen(op);
int c;
int renshu = , zf = ;
for(int i = ; i <= zlr; i ++) {
c = ;
for(int j = ; j < lx; j ++)
if(node[i].id[j + ] == op[j])
c ++;
if(c == lx) {
renshu ++;
zf += node[i].score;
}
}
printf("Case %d: %d %s\n", t, x, op);
if(renshu == )
printf("NA\n");
else {
printf("%d %d\n", renshu, zf);
}
} else if(x == ){
for(int kk = ; kk < maxn; kk ++) {
endd[kk].ren = ;
endd[kk].room = ;
num[kk].ren = ;
num[kk].room = ;
}
int lc = strlen(op);
int d = ;
int nnn = ;
int naa = ;
for(int i = ; i <= zlr; i ++) {
d = ;
for(int j = ; j < lc; j ++) {
if(node[i].id[j + ] == op[j])
d ++;
}
if(d == ) {
naa ++;
int rec = ;
for(int h = ; h <= ; h ++)
rec = rec * + (node[i].id[h] - '');
num[rec].room = rec;
num[rec].ren ++;
}
}
printf("Case %d: %d %s\n", t, x, op);
if(naa == )
printf("NA\n");
else {
for(int r = ; r <= ; r ++) {
if(num[r].ren != ) {
nnn ++;
endd[nnn].ren = num[r].ren;
endd[nnn].room = num[r].room;
}
}
sort(endd + , endd + + nnn, cmpp);
for(int u = ; u <= nnn; u ++)
printf("%d %d\n", endd[u].room, endd[u].ren);
}
} else printf("Case %d: %d %s\nNA\n", t, x, op);
}
return ;
}

最后一道题真的是看了很久才发现错误 第一次考试太紧张 希望下次甲级也会顺利吧 可惜的是证书还没拿到拿到之后再补图 8 之后的日子可以继续安心学新的东西了 想想就开心呢
PAT-2018年冬季考试-乙级的更多相关文章
- PAT-2019年冬季考试-乙级(题解)
很荣幸这次能够参加乙级考试,和大佬们同台竞技了一次,这篇博客,进行介绍这次2019冬季的乙级考试题解. 7-1 2019数列 (15分) 把 2019 各个数位上的数字 2.0.1.9 作为一个数列的 ...
- PAT(甲级)2018年冬季考试
1152 Google Recruitment 思路:判断素数 #include<bits/stdc++.h> using namespace std; const int maxn = ...
- PAT甲级2019冬季考试题解
A Good In C纯模拟题,用string数组读入数据,注意单词数量的判断 #include<bits/stdc++.h> using namespace std; ; ][]; in ...
- 2018年秋PTA乙级回顾
距离上次我一个人参加PAT考试已经过去快一个学期了,想想上次自己也是搞笑,自己一个人被这个书包就去了ZZ,人生地不熟的,乘坐公交车还坐反了.考完试因为不知道要等到考试结束就可以领取成绩证书,自己连那张 ...
- PAT 天梯赛 L1-005. 考试座位号 【MAP标记】
题目链接 https://www.patest.cn/contests/gplt/L1-005 题意 有一个 考生号,一个试机座位,一个考试座位,给出试机座位,查询 考生号和考试座位 思路 MAP + ...
- PAT-2019年冬季考试-甲级 7-3 Summit (25分) (邻接矩阵存储,直接暴力)
7-3 Summit (25分) A summit (峰会) is a meeting of heads of state or government. Arranging the rest ar ...
- PAT 2018 春
A 1140 Look-and-say Sequence 简单模拟.可能要注意字符串第一个字符和最后一个字符的处理. #include <cstdio> #include <iost ...
- 2018年冬季寒假作业4--PTA 抓老鼠啊~亏了还是赚了?
1. 实验代码; #include<stdio.h> ; void search(char a,int *p){ if(a=='X'){ ) *p=; ; printf("U&q ...
- 2018年冬季寒假作业4--PTA 币值转换
1. 实验代码: #include<stdio.h> int main (void) { int n, initial_n; scanf("%d", &n); ...
随机推荐
- Python读取 csv文件中文乱码处理
需求:按行解析读取csv文件存入关系型数据库——主要是中文字体解析:遇到的问题:直接解析出来的数据为list形式,而且编码格式为unicode;解决问题:前提了解: 中文编码的规则 —— GB2312 ...
- PTA基础编程题目集7-3逆序三位数
7-3 逆序的三位数 (10 分) 程序每次读入一个正3位数,然后输出按位逆序的数字.注意:当输入的数字含有结尾的0时,输出不应带有前导的0.比如输入700,输出应该是7. 输入格式: 每个测试是一个 ...
- C# string 转 byte[]
string 转 byte[] /// <summary> /// string 转 byte /// </summary> /// <param name=" ...
- Springboot 拦截器(HandlerInterceptorAdapter)中注入无效
1,传统filter和HandlerInterceptorAdapter的区别 springboot对传统Filter进行增强,添加更多细粒度的操作,分别实现预处理.后处理(调用了Service并返回 ...
- R语言爬虫:CSS方法与XPath方法对比(表格介绍)
css 选择器与 xpath 用法对比 目标 匹配节点 CSS 3 XPath 所有节点 ~ * //* 查找一级.二级.三级标题节点 <h1>,<h2>,<h3> ...
- ACM数论-卡特兰数Catalan
Catalan 原理: 令h(0)=1,h(1)=1,catalan 数满足递归式: (其中n>=2) 另类递推公式: 该递推关系的解为: (n=1,2,3,...) 卡特兰数的应用实质上都是递 ...
- 为什么我要放弃javaScript数据结构与算法(第九章)—— 图
本章中,将学习另外一种非线性数据结构--图.这是学习的最后一种数据结构,后面将学习排序和搜索算法. 第九章 图 图的相关术语 图是网络结构的抽象模型.图是一组由边连接的节点(或顶点).学习图是重要的, ...
- [Real World Haskell翻译]第23章 GUI编程使用gtk2hs
第23章 GUI编程使用gtk2hs 在本书中,我们一直在开发简单的基于文本的工具.虽然这些往往是理想的接口,但有时图形用户界面(GUI)是必需的.有几个Haskell的GUI工具包是可用的.在本章中 ...
- Codeforces Contest 870 前三题KEY
A. Search for Pretty Integers: 题目传送门 题目大意:给定N和M个数,从前一个数列和后一个数列中各取一个数,求最小值,相同算一位数. 一道水题,读入A.B数组后枚举i.j ...
- 成都Uber优步司机奖励政策(4月6日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...