题目传送门 #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<map> #include<string> using namespace std; int main() { int M,N,S,i,j,flag=0; string str; map<string,int>mp;
美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014 年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧! 输入格式: 输入在一行中给出正方形边长 N(3≤
【PAT】 乙级 B1001 害死人不偿命的(3n+1)猜想 (15 分) 卡拉兹(Callatz)猜想: 对任何一个正整数 n,如果它是偶数,那么把它砍掉一半;如果它是奇数,那么把 (3n+1) 砍掉一半。这样一直反复砍下去,最后一定在某一步得到 n=1。卡拉兹在 1950 年的世界数学家大会上公布了这个猜想,传说当
1002 A+B for Polynomials part 1, 1.1 自己解法(未全对) 使用两个map去存储数据 #include <iostream> using namespace std; #include <map> #include <algorithm> #include <iomanip> class MyCompare { public: bool operator()(int v1, int v2) {
1164 Good in C (20 point(s)) 字符串 题目 When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows? Input Specification: Each input file contains one test case. For each case, the first part gives the 26 c
1061 Dating part 1, 1.1 题目理解 INPUT: 两对字符串 前两个字符串共有且位置相同的第一个大写字母 ABCDEFG 表示 星期几前两个字符串共有且位置相同且在第一个大写字母后边的数字或者大写字母 表示 时后两个字符串共有且位置相同的字母所在位置代表 分 OUTPUT: 约会时间
1011 A+B 和 C (15 分) 给定区间 [,] 内的 3 个整数 A、B 和 C,请判断 A+B 是否大于 C。 输入格式: 输入第 1 行给出正整数 T (≤10),是测试用例的个数。随后给出 T 组测试用例,每组占一行,顺序给出 A、B 和 C。整数间以空格分隔。 输出格式: 对每组测试用例,在一行中输出 Case #X: tr
在下面的程序里,我们将在字符串中对正则表达式进行匹配。 如果是简单模式,使用 Match 方法便可: ok, _ := regexp.Match(pat, []byte(searchIn)) 变量 ok 将返回 true 或者 false, 我们也可以使用 MatchString: ok, _ := regexp.MatchString(pat, searchIn) 更多方法中,
1040. 有⼏个PAT 字符串APPAPT中包含了两个单词“PAT”,其中第⼀个PAT是第2位§,第4位(A),第6位(T); 第⼆个PAT是第3位§,第4位(A),第6位(T)。 现给定字符串,问⼀共可以形成多少个PAT? 输⼊格式: 输⼊只有⼀⾏,包含⼀个字符串,⻓度不超过105,只包含P、A、T三种字⺟。 输出格式: 在⼀⾏
本题翻译: 题目给出两个数字,一个是N,一个是K,判断N是否为回文数字,如果不是,将N转换成回文数字后加N,再判断是否为回文数字,循环K次,直到看见回文数字为止,如果在K次循环之内没有看见回文数字,则输出循环了K次的数字,其中个位数默认是回文数字。 本题思路: 写两个函数,一个是判断回文函数,
文章目录 一、答案二、坑点 一、答案 #include <iostream> #include <math.h> using namespace std; int judge_prime(long int num); //判断质数的函数 long int base_change(long int check_num,int base_system); //十进制转换成其他进制的函数 lo
文章目录 前言1110 Complete Binary Tree (25 分)分析AC代码简化 总结 前言 今日完成任务: 1、单词150旧+50新 2、英语阅读手译一篇 3、英语练字 4、Java核心技术(回顾基础篇)(1.30h) 5、springBoot框架回顾(1.30h) 6、阅读毕设参考材料 7、Pat一题(1110) 提示:以下是本篇文章
1048 Find Coins (25 分) Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requireme
题目:1069 微博转发抽奖 (20 分) 来源:PAT (Basic Level) Practice 传送门 1069 微博转发抽奖 题面 题意:给定总转法次数,间隔次数和起始位置,从起始位置每间隔指定次数抽取一个人,如果该位置的人中过奖,就顺延找到没中奖的继续按以上流程操作。 思路:见代码 Code 点击查看代码
题目:1048 数字加密 (20 分) 来源:PAT (Basic Level) Practice 传送门 1048 数字加密 题面 题意:给定两个数字A,B,按给定规律对奇偶位分别操作。 思路:建议字符串输入,如果一个字符串长度小于另一个的话,前面要用零补上。 Code 点击查看代码 #include <iostream> #include <stri
题目:1053 住房空置率 (20 分) 来源:PAT (Basic Level) Practice 传送门 1053 住房空置率 题面 题意:注意要读懂题意,超过一半且观察期大于阈值的是“空置“,超过一半但观察期没大于阈值的是 “可能空置” 思路:见代码 Code 点击查看代码 #include <bits/stdc++.h> using name
题目:1057 数零壹 (20 分) 来源:PAT (Basic Level) Practice 传送门 1057 数零壹 题面 题意:统计字符串中字母序号之和并转化为二进制,输出该二进制数的0和1的个数 思路:见代码 Code 点击查看代码 #include<iostream> #include<string> using namespace std; typedef long
题目:1086 就不告诉你 (15 分) 来源:PAT (Basic Level) Practice 传送门 1086 就不告诉你 题面 题意:倒着输出两数乘积 思路:水题,注意1000*1000这种的应该输出1,没有前导零。 Code 点击查看代码 #include <bits/stdc++.h> using namespace std; int main(){ long long a,b,
题目:1087 有多少不同的值 (20 分) 来源:PAT (Basic Level) Practice 传送门 1087 有多少不同的值 题面 题意:输出题目中算式不同答案的个数 思路:见代码 Code 点击查看代码 #include <bits/stdc++.h> using namespace std; int num[20000]; int main(){ int n,ans=0,k; c
题目:1084 外观数列 (20 分) 来源:PAT (Basic Level) Practice 传送门 1084 外观数列 题面 题意:给定d,n,按给定规律求第n项 思路:感觉就是一种行压缩,详细见代码 Code 点击查看代码 #include <bits/stdc++.h> using namespace std; int main(){ string d; int n,k; cin>>
题目:1083 是否存在相等的差 (20 分) 来源:PAT (Basic Level) Practice 传送门 1083 是否存在相等的差 题面 题意:给定1、2、……、N的一个序列,求第i个数字a[i]与i的差值的绝对值的出现次数≥2的该绝对值与出现次数,按绝对值大小降序输出 思路:结构体存储,注意差值为0的情况 C
1164 Good in C (20 分) When your interviewer asks you to write "Hello World" using C, can you do as the following figure shows? Input Specification: Each input file contains one test case. For each case, the first part gives the 26 capital Engli
1092 To Buy or Not to Buy (20 分) Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in who
题目:1040 有几个PAT (25 分) 来源:PAT (Basic Level) Practice 传送门 1040 有几个PAT 题面 题意:给定字符串,找到其中可以形成几个"PAT"非连续子串 思路: 先扫一遍,得出字符"T"的个数,然后再扫一遍,碰到"P"就把统计p的变量加一,遇到"T"就把统计T的变量减一,遇到"A"就把此时P和T的
题目:1047 编程团体赛 (20 分) 来源:PAT (Basic Level) Practice 传送门 1047 编程团体赛 题面 题意:统计每个队伍的分数,找出最大值和其对应的队伍 思路:简单题,看代码即可 Code 点击查看代码 #include <bits/stdc++.h> using namespace std; int sum[1500]; int main(){ in