1091 N-自守数

代码:

#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 ;
}

1092 最好吃的月饼

代码:

#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 ;
}

1093 字符串 A + B

代码:

#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 ;
}

1094 谷歌的招聘

代码:

#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 ;
}

1095 解码 PAT 准考证

代码:

#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年冬季考试-乙级的更多相关文章

  1. PAT-2019年冬季考试-乙级(题解)

    很荣幸这次能够参加乙级考试,和大佬们同台竞技了一次,这篇博客,进行介绍这次2019冬季的乙级考试题解. 7-1 2019数列 (15分) 把 2019 各个数位上的数字 2.0.1.9 作为一个数列的 ...

  2. PAT(甲级)2018年冬季考试

    1152 Google Recruitment 思路:判断素数 #include<bits/stdc++.h> using namespace std; const int maxn = ...

  3. PAT甲级2019冬季考试题解

    A Good In C纯模拟题,用string数组读入数据,注意单词数量的判断 #include<bits/stdc++.h> using namespace std; ; ][]; in ...

  4. 2018年秋PTA乙级回顾

    距离上次我一个人参加PAT考试已经过去快一个学期了,想想上次自己也是搞笑,自己一个人被这个书包就去了ZZ,人生地不熟的,乘坐公交车还坐反了.考完试因为不知道要等到考试结束就可以领取成绩证书,自己连那张 ...

  5. PAT 天梯赛 L1-005. 考试座位号 【MAP标记】

    题目链接 https://www.patest.cn/contests/gplt/L1-005 题意 有一个 考生号,一个试机座位,一个考试座位,给出试机座位,查询 考生号和考试座位 思路 MAP + ...

  6. 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 ...

  7. PAT 2018 春

    A 1140 Look-and-say Sequence 简单模拟.可能要注意字符串第一个字符和最后一个字符的处理. #include <cstdio> #include <iost ...

  8. 2018年冬季寒假作业4--PTA 抓老鼠啊~亏了还是赚了?

    1. 实验代码; #include<stdio.h> ; void search(char a,int *p){ if(a=='X'){ ) *p=; ; printf("U&q ...

  9. 2018年冬季寒假作业4--PTA 币值转换

    1. 实验代码: #include<stdio.h> int main (void) { int n, initial_n; scanf("%d", &n); ...

随机推荐

  1. excel 开头 结尾,中间 类似 SQL like ab% ,%ab ,%ab%

    excel  开头 结尾,中间  类似 SQL like 'ab%'  ,'%ab'  ,'%ab%' 在R2 单元格  查找   ab开头,ab结尾 =Search("ab",R ...

  2. Hadoop入门学习路线

    走上大数据的自学之路....,Hadoop是走上大数据开发学习之路的第一个门槛. Hadoop,是Apache的一个开源项目,开发人员可以在不了解分布式底层细节,开发分布式程序,充分利用集群进行高速运 ...

  3. QK对中断的特殊处理

    1.QK的特性 QK(Quntum Kernel)是一个抢占式.基于优先级实时微内核.一个多任务调度器: QK不同于传统的RTOS,是非阻塞的,并且只用了一个stack: 对QK中的任务来说,采用了I ...

  4. Centos配置网卡子接口

    1.检查OS是否加载802.1q模块: 方法一: [root@rs2 ~]# modinfo 8021q 方法二: [root@rs2 ~]# modinfo -F filename 8021q 方法 ...

  5. war2 洛谷模拟赛day2 t3 状压

    (new )   war2 题解:总体数据而言,我们很容易想到着就是DP啊,我们DP数组,用状态压缩,代表有那些点已经被占领过了,代表上一次我占的是那个.对于每一次状态转移,若当前我们要占领的Port ...

  6. Oracle,SQL Server 数据库较MySql数据库,Sql语句差异

    原文:Oracle,SQL Server 数据库较MySql数据库,Sql语句差异 Oracle,SQL Server 数据库较MySql数据库,Sql语句差异 1.关系型数据库 百度百科 关系数据库 ...

  7. kafka配置参数详解

    Broker  Configs Property Default Description broker.id   每个broker都可以用一个唯一的非负整数id进行标识:这个id可以作为broker的 ...

  8. java.lang.RuntimeException: HRegionServer Aborted

    java.lang.RuntimeException: HRegionServer Aborted 当我们启动hbase集群的时候,刚启动时每个节点上的进程都显示正常,过一会其他两个节点上的HRegi ...

  9. CakePHP2.x 发送邮件

    cake提供了多种发送邮件的方法,并且简单实用.以2.x为例 第一步 创建并添加邮件配置信息 拷贝app\Config\email.php.default 为email.php 打开在EmailCon ...

  10. redis 问题记录

    摘抄来自:https://zhuoroger.github.io/ 1.slowlog和排队延时 slowlog是排查性能问题关键监控指标.它是记录Redis queries运行时间超时特定阀值的系统 ...