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. 帝国cms教程父栏目和子栏目都能在当前栏目高亮

    首先在/e/class/userfun.php这个文件里面加上下面代码.上面父栏目的,下面子栏目的.红色代表css样式.自定义吧 function currentPage($classid,$this ...

  2. 最新版的stm32f1xx.h文件中取消了u8, u16, u32的类型定义

    使用芯片stm32f103zet6和stm32l151c8t6,在移植程序时发现,编译器提示u8未定义: 在Keil MDK 开发环境里,st定义无符号32位整形数据有很多种表示方法: 1 unsig ...

  3. Python学习笔记八:文件操作(续),文件编码与解码,函数,递归,函数式编程介绍,高阶函数

    文件操作(续) 获得文件句柄位置,f.tell(),从0开始,按字符数计数 f.read(5),读取5个字符 返回文件句柄到某位置,f.seek(0) 文件在编辑过程中改变编码,f.detech() ...

  4. 数据结构之 AVL个人笔记

    从这位前辈的博客园中学习的数据结构:https://www.cnblogs.com/skywang12345/ 非常感谢这位前辈. 以下文章摘录于 :skywang12345的博客园:转载请注明出处: ...

  5. 解决应用程序无法正常启动0xc0150002等问题

    1.在程序运行出错的时候,右键“我的电脑”,然后点击“管理”→“事件查看器”→“Windows 日志”→“应用程序”,查看错误信息: 1> “E:\IPCam_share\ARP\數據處理\Hg ...

  6. Matlab R2018a版离线使用帮助文档方法

    转载自:Matlab R2018a版离线使用帮助文档方法 问题 Matlab R2018a版本安装后,帮助文档默认为在线方式,需要使用账号登录,如果没有激活密钥或许可证编号,就无法使用帮助文档了. 方 ...

  7. java中reader和writer部分的笔记

    输入和输出流:获取流对象从文件中获取InputStream in = Files.newInputStream(path);OutputStream out = Files.newOutputStre ...

  8. 前端必备的Nginx学习

    由于机缘巧合,认识了一些朋友,给我介绍了搬瓦工的网站.买了一个国外的服务器,既可以FQ又拥有了一个搭载 Centos 6 的服务器.一年19.99美元,折合人民币也就130左右,一键搭建.有兴趣可以点 ...

  9. 【LG1975】[国家集训队]排队

    [LG1975][国家集训队]排队 题面 洛谷 题解 又是一个偏序问题 显然\(CDQ\) 交换操作不好弄怎么办? 可以看成两次删除两次插入 排序问题要注意一下 代码 #include <ios ...

  10. 文件同步 单向rsync 双向unison 监控inotifywait 免密登录

    1.负载均衡中文件同步必不可少,我这边选择rsync来实现文件同步 rsync同步文件机制更适用于单向文件同步,可配合unison实现双向同步功能. 实现同步的两种方法 一:ssh方法 rsync - ...