E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
PAT甲级乙级
输出PATest(20)-PAT
乙级
真题
解题思路:用unordered_map存储每个字母出现的个数,然后按照顺序遍历输出即可#includeusingnamespacestd;intmain(){stringstr;cin>>str;unordered_mapmp;for(inti=0;i0||mp['A']>0||mp['T']>0||mp['e']>0||mp['s']>0||mp['t']>0){if(mp['P']-->0){
六弦绿漪。
·
2023-07-18 19:48
PAT乙级
哈希算法
c++
算法
输出PATest(20)-PAT
乙级
给定一个长度不超过10000的、仅由英文字母构成的字符串。请将字符重新调整顺序,按“PATestPATest….”这样的顺序输出,并忽略其它字符。当然,六种字符的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按PATest的顺序打印,直到所有字符都被输出。输入格式输入在一行中给出一个长度不超过10000的、仅由英文字母构成的非空字符串。输出格式在一行中按题目要求输出排序后的字符串。题目
newcomer1235
·
2023-07-18 19:47
pat
算法
PAT
乙级
-1043. 输出PATest(20)-详解+代码
题目:PAT
乙级
-1043.输出PATest(20)给定一个长度不超过10000的、仅由英文字母构成的字符串。
水舞残枫
·
2023-07-18 19:45
PAT乙级
PAT
编程
刷题
PAT乙级
c语言
PAT甲级
题目1056 Mice and Rice
代码:#include#include#definemaxn1010usingnamespacestd;structmouse{intweight;intrank;}mice[maxn];intmain(){intNP,NG;intRat,Group;inti,j,k,front,current,u,max;vectorSeq,temp;scanf("%d%d",&NP,&NG);for(i=0;
Mr Zhang.
·
2023-07-18 15:15
c语言
PAT甲级
1056 Mice and Rice
题解题目要表达的意思特别绕,没看翻译之前,一度怀疑自己的水平?首先给你一个随机比赛序列。然后每NG个数的人在一个小组比赛。这个小组最肥的老鼠参加下一场比赛,在这一轮(所有的小组赛比完)淘汰的赋予排名,胜利的进入下一场比赛,重复上面的操作,一直找出冠军。注意:到最后不足NG人也被视为一组就拿题目中的数据来说:608一组7105一组914一组23一组4组最多诞生4个强人。所以所有淘汰的人排名是5;然后
哦啦哦啦!
·
2023-07-18 15:44
PAT甲级
PAT甲级
-1056 Mice and Rice (25分)
点击链接
PAT甲级
-AC全解汇总题目:MiceandRiceisthenameofaprogrammingcontestinwhicheachprogrammermustwriteapieceofcodetocontrolthemovementsofamouseinagivenmap.Thegoalofeachmouseistoeatasmuchriceaspossibleinordertobec
邂逅模拟卷
·
2023-07-18 15:42
#
PAT
算法
c++
PAT甲级
:1056 Mice and Rice
题目描述:MiceandRiceisthenameofaprogrammingcontestinwhicheachprogrammermustwriteapieceofcodetocontrolthemovementsofamouseinagivenmap.ThegoalofeachmouseistoeatasmuchriceaspossibleinordertobecomeaFatMouse.F
正在黑化的KS
·
2023-07-18 15:39
PAT
python
算法
pat考试
1051 Pop Sequence (
PAT甲级
)
1051.PopSequence(25)-
PAT甲级
真题(栈模拟)_柳婼的博客-CSDN博客柳婼的解法比较直观一些。
天天AZ
·
2023-07-18 15:09
PAT甲级
算法
pat考试
1064 Complete Binary Search Tree (
PAT甲级
)
这道题柳婼的解法很巧妙,理解上稍稍抽象,也就是当中序遍历时,level[r]=inorder[t++];我按照她的思路写的代码如下:#include#include#includeintN,t;std::vectorinorder,level;voidin(intr){if(r>=N){return;}in(2*r+1);level[r]=inorder[t++];in(2*r+2);}intma
天天AZ
·
2023-07-18 15:09
PAT甲级
算法
pat考试
1054 The Dominant Color (
PAT甲级
)
#include#includeintM,N,t,half;std::mapmp;intmain(){scanf("%d%d",&M,&N);half=M*N/2;for(inti=0;ihalf){printf("%d",t);return0;}}}return0;}题目如下:Behindthescenesinthecomputer'smemory,colorisalwaystalkedabou
天天AZ
·
2023-07-18 15:09
PAT甲级
算法
pat考试
PAT甲级
1056. Mice and Rice (25)
MiceandRiceisthenameofaprogrammingcontestinwhicheachprogrammermustwriteapieceofcodetocontrolthemovementsofamouseinagivenmap.ThegoalofeachmouseistoeatasmuchriceaspossibleinordertobecomeaFatMouse.Firstt
liaotl10
·
2023-07-18 15:39
PAT甲级
PAT甲级
1056 【Mice and Rice】 (25)
补充:2018.8.19更新,哦凑再写一遍果然思路清晰了很多,代码也缩减到了47行。用一个vector数组group记录当前所有的比赛顺序,再按每ng个进行从前往后分组,将每个小组第一push到vector数组tem中,其余不是小组第一的排名就是当前tem数组的大小加1(因为有了前tem名),然后令group等于tem,继续循环,最后将仅存的一个人排名设为第一。以及ng的范围是小于1e3,np的范
gq97
·
2023-07-18 15:08
PAT
模拟
PAT
C++
模拟
1056 Mice and Rice -
PAT甲级
题目描述MiceandRiceisthenameofaprogrammingcontestinwhicheachprogrammermustwriteapieceofcodetocontrolthemovementsofamouseinagivenmap.ThegoalofeachmouseistoeatasmuchriceaspossibleinordertobecomeaFatMouse.Fi
星辰浩宇
·
2023-07-18 15:37
pat甲级
1056 Mice and Rice (
PAT甲级
)
这道题我觉得柳婼的解法有点把题复杂化了,其实简单模拟就可以完成。cnt是当前的group数,会选出cnt个进入下一轮比赛,所以当前被淘汰的排名为cnt+1。又想了下,觉得柳婼这里queue用得还是挺巧妙的,根据她的思路把她的解法稍微简化了下,这是我的版本。#include#include#includeintN,g,maxx,pivot,cnt,t,sz;std::vectorw,rank;std
天天AZ
·
2023-07-18 15:35
PAT甲级
算法
c++
pat考试
1069 The Black Hole of Numbers (
PAT甲级
)
可以用dowhile来改进……#include#include#includeintmain(){std::stringa,b,tmp;std::cin>>a;while(a.size()<4){a="0"+a;}if(a=="6174"){sort(a.begin(),a.end());b=a;reverse(a.begin(),a.end());tmp=std::to_string(std::
天天AZ
·
2023-06-20 05:16
PAT甲级
c++
算法
pat考试
1071 Speech Patterns (
PAT甲级
)
写完后看柳婼解法发现了一个函数isalnum()可以判断是否字母或者数字,很方便,于是改写了一下。#include#include#include#includeintmain(){std::stringstr,tmp,res;intcnt;std::mapans;getline(std::cin,str);for(inti=0;ifirst;cnt=ans.begin()->second;for
天天AZ
·
2023-06-20 05:46
PAT甲级
算法
c++
pat考试
python3实现PAT
乙级
算法题库全集
最近在学python,我把一些代码贴到这里,不定期更新,欢迎交流。因为有些算法有时间和空间要求,建议找个oj平台跑一遍。现在在用的算法平台链接:https://pintia.cn/文章目录1、害死人不偿命的(3n+1)猜想2、写出这个数3、我要通过!4、成绩排名5、继续(3n+1)猜想6、换个格式输出整数7、素数对猜想8、数组元素循环右移问题9、说反话10、一元多项式求导11、A+B和C12、数字
洛阳山
·
2023-06-19 23:38
python
python
算法
PTA
乙级
PTA
乙级
(寒假刷完计划)写在前面,刷完PTA上的(PAT(BasicLevel)Practice(中文))题目,一共110题目如果我在刷的时候有磕磕绊绊,会写下题解或者tipstip**:不要美观,要快
rainbowsea_1
·
2023-06-19 23:08
算法
c++
1079 Total Sales of Supply Chain (
PAT甲级
)
#include#include#includeconstintMAXN=100000;intN,K;intamount[MAXN]={0};std::vectorvec[MAXN];doubleP,r,res;voiddfs(intk,intdepth){if(vec[k].empty()){res+=amount[k]*P*pow(r/100+1,depth);return;}for(inti
天天AZ
·
2023-06-18 21:00
PAT甲级
pat考试
1072 Gas Station (
PAT甲级
)
#include#include#include#include#include#includeconstintMAXN=1011;constintINF=999999999;structnode{intid;intdist;node(int_id,int_dist):id(_id),dist(_dist){}};structstation{std::stringid;doubleminDist;
天天AZ
·
2023-06-18 15:28
PAT甲级
pat考试
1073 Scientific Notation (
PAT甲级
)
1073.ScientificNotation(20)-
PAT甲级
真题_柳婼的博客-CSDN博客先贴柳婼的解题,她的方法感觉不容易有疏漏。
天天AZ
·
2023-06-18 15:57
PAT甲级
c++
pat考试
c++ pat
乙级
-------1002 读入一个正整数 n,计算其各位数字之和,用汉语拼音写出和的每一位数字。
1002写出这个数(20分)读入一个正整数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。输入格式:每个测试输入包含1个测试用例,即给出自然数n的值。这里保证n小于10100。输出格式:在一行内输出n的各位数字之和的每一位,拼音数字间有1空格,但一行中最后一个拼音数字后没有空格。输入样例:1234567890987654321123456789输出样例:yisanwu测试点结果耗时内存0答案
努力奋斗的小张同学
·
2023-06-18 04:09
C++
【PAT刷题甲级】部分笔记1001-1064~(上)
写在前面这里C++菜鸟一枚~暑假将近两个月刷
PAT甲级
的笔记在此,虽然最终也没有取得满意的结果,但是不可否认,还是从中学到了很多,是我准备的还不够充分,希望能给刷题的同学们一些帮助。
C_greenbird
·
2023-06-17 18:05
PAT甲级
c++
PAT
数据结构
算法
1077 Kuchiguse (
PAT甲级
)
#include#include#include#includeintN,sz,length;std::stringline;std::vectorvec;intmain(){std::cin>>N;getline(std::cin,line);sz=257;for(inti=0;i
天天AZ
·
2023-06-16 19:19
PAT甲级
c++
pat考试
1074 Reversing Linked List (
PAT甲级
)
#include#include#includeconstintMAXN=100001;structnode{intdata;intnext;};intcurr,N,K,address;nodevec[MAXN];std::vectorans;intmain(){scanf("%d%d%d",&curr,&N,&K);for(inti=0;i
天天AZ
·
2023-06-16 19:19
PAT甲级
c++
pat考试
1078 Hashing (
PAT甲级
)
#include#include#include#includeintMSize,N,key;std::vectorvisited;boolisPrime(intp){if(p==1){returnfalse;}if(p==2||p==3){returntrue;}intsqr=(int)sqrt(p*1.0);for(inti=2;i<=sqr;++i){if(p%i==0){returnfal
天天AZ
·
2023-06-16 19:49
PAT甲级
pat考试
1075 PAT Judge (
PAT甲级
)
这道题目有些小细节比较复杂,比如输入的时候“partial_score_obtainediseither−1ifthesubmissioncannotevenpassthecompiler”,输出的时候“Ifauserhasneversubmittedasolutionforaproblem,then"-"mustbeprintedatthecorrespondingposition”,而且“Fo
天天AZ
·
2023-06-16 19:17
PAT甲级
pat考试
1083 List Grades (
PAT甲级
)
#include#include#includestructnode{std::stringname;std::stringid;intgrade;};boolcmp(node&a,node&b){returna.grade>b.grade;}intmain(){intN,g1,g2,cnt;std::vectorvec;std::cin>>N;vec.resize(N);for(inti=0;i
天天AZ
·
2023-06-14 17:57
PAT甲级
pat考试
1088 Rational Arithmetic (
PAT甲级
)
这道题折磨了我很久,最后发现bug竟然是因为使用了abs()函数在longlong类型上……必须使用llabs().或者像其他人一样先usingnamespacestd;就可以直接用abs()。https://bbs.csdn.net/topics/392139827?list=lz这里有相关的讨论。“C++标准中,cstdio声明的是namespacestd{intabs(intn);longi
天天AZ
·
2023-06-14 17:57
PAT甲级
c++
pat考试
1081 Rational Sum (
PAT甲级
)
#include#includeintN;longa,b;longlongnumerator,denominator,integer;longlonggcd(longlongc,longlongd){returnc==0?d:gcd(d%c,c);}voidcalSum(longc,longd){numerator=numerator*d+denominator*c;denominator=den
天天AZ
·
2023-06-14 17:26
PAT甲级
pat考试
PAT甲级
入门刷题记录(二)
题目导航1017QueueingatBank1019GeneralPalindromicNumber1020TreeTraversals1022DigitalLibrary1023HaveFunwithNumbers1024PalindromicNumber*大数加板子1025PATRanking1027ColorsinMars1028ListSorting1029Median1031HelloW
我是一道数学题
·
2023-06-13 03:01
PAT
PAT甲级
1130-Infix Expression(DFS相关)
一.题目Givenasyntaxtree(binary),youaresupposedtooutputthecorrespondinginfixexpression,withparenthesesreflectingtheprecedencesoftheoperators.InputSpecification:Eachinputfilecontainsonetestcase.Foreachcase
Howie_9891
·
2023-06-12 11:06
造价咨询企业资质走了!以后考造价还有用吗?
就在昨天,国务院印发的《国务院关于在自由贸易试验区开展“证照分离”改革全覆盖试点的通知》像一颗重磅炸弹,在造价圈引起了热烈的讨论,究其原因,是该《通知》里的这两条:在自贸区取消了工程造价咨询企业甲、
乙级
资质的审批
工程人帮
·
2023-06-12 05:54
1086 Tree Traversals Again (
PAT甲级
)
#include#include#include#include#includeintN,t;std::stringstr;std::stackvec;std::vectorpreorder,inorder,postorder;std::mapmp;voidconstruct(intpreL,intpreR,intinL,intinR){if(preL==preR){return;}intloc=
天天AZ
·
2023-06-11 16:53
PAT甲级
pat考试
Broken Keyboard (20)-
PAT甲级
试题
Onabrokenkeyboard,someofthekeysarewornout.Sowhenyoutypesomesentences,thecharacterscorrespondingtothosekeyswillnotappearonscreen.Nowgivenastringthatyouaresupposedtotype,andthestringthatyouactuallytypeo
柳婼
·
2023-06-11 16:53
PAT
1084 Broken Keyboard (
PAT甲级
)
1084.BrokenKeyboard(20)-
PAT甲级
试题_柳婼的博客-CSDN博客#include#include#include#includestd::stringa,b;std::setsta
天天AZ
·
2023-06-11 16:51
PAT甲级
pat考试
2023夏
PAT甲级
题解
目录总结:A-1题意:思路:AC代码:A-2题意:AC代码:A-3题意:思路:A-4BigNumber题意:思路:AC代码总结:第一次打
PAT甲级
可能也是最后一次打了,可能因为今天蓝桥国赛,就我一个人考
永远有多远.
·
2023-06-11 06:40
深度优先
算法
图论
c++
c语言旧键盘打字,PAT
乙级
1033. 旧键盘打字 C语言
1033.旧键盘打字(20)题目:旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?输入格式:输入在2行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过105个字符的串。可用的字符包括字母[a-z,A-Z]、数字0-9、以及下划线“_”(代表空格)、“,”、“.”、“
sxtagz
·
2023-06-11 03:18
c语言旧键盘打字
PAT
乙级
1033 旧键盘打字 python
题目思路因为坏键盘的输入是大写字母遍历输入的字符,将输入字母的字符转换为大写与坏键盘对比:如果‘+’坏掉,当字母字符不在坏键盘之列,则是小写时,字符才能输出代码importsysbad_key,_=sys.stdin.readline().split('\n')input_,_=sys.stdin.readline().split('\n')print_=''forstring_ininput_:
又南又难
·
2023-06-11 03:04
PAT乙级
python
pat考试
1089 Insert or Merge (
PAT甲级
)
#include#include#includeintN,j,k,m,begin,end;std::vectora,b;boolflag=true;intmain(){scanf("%d",&N);a.resize(N);b.resize(N);for(inti=0;ib[j+1]){break;}}for(inti=j+1;i
天天AZ
·
2023-06-09 06:47
PAT甲级
pat考试
Insertion or Heap Sort (25)-
PAT甲级
真题(堆排序)
AccordingtoWikipedia:Insertionsortiterates,consumingoneinputelementeachrepetition,andgrowingasortedoutputlist.Eachiteration,insertionsortremovesoneelementfromtheinputdata,findsthelocationitbelongswith
柳婼
·
2023-06-09 06:47
PAT
1108 Finding Average (
PAT甲级
)
#include#include#include#includebooljudge(std::stringstr){intcnt=0;std::strings=".";for(inti=0;i'9')&&str[i]!='.'&&str[i]!='-'){returnfalse;}if(str[i]=='.'){++cnt;}}if(cnt>1){returnfalse;}intpos=str.f
天天AZ
·
2023-06-09 06:17
PAT甲级
pat考试
1092 To Buy or Not to Buy (
PAT甲级
)
1092.ToBuyorNottoBuy(20)-
PAT甲级
真题_柳婼的博客-CSDN博客柳婼的解法要更清晰一些。
天天AZ
·
2023-06-09 06:17
PAT甲级
pat考试
1091 Acute Stroke (
PAT甲级
)
这道题用dfs做的话,因为递归太多层,堆栈溢出,有两个测试点过不了;所以用bfs。但令我百思不得其解的是,我没用方向变量x[6],y[6],z[6],直接老老实实算每一个方向的话,最后一个测试点过不了;但理论上来说,实现的本质应该是完全一样的。如有大神看到,望不吝赐教。无法全部通过的写法;这里的i,j,k即AC代码中的curri,currj,currk:if(i+1=0&&vec[i-1][j][
天天AZ
·
2023-06-09 06:17
PAT甲级
算法
pat考试
1112 Stucked Keyboard (
PAT甲级
)
写完后看柳婼的解法,其实可以直接数重复了几次,我这个写法有点复杂化了。原代码:#include#include#includeintmain(){intk,j;boolflag;std::setst,printed;std::stringstr;std::cin>>k;std::cin>>str;for(inti=1;i#include#includeintmain(){intk,cnt;std:
天天AZ
·
2023-06-09 06:16
PAT甲级
c++
pat考试
1119 Pre- and Post-order Traversals (
PAT甲级
)
后来看了一下其他人的解法,inorder可以在建树过程中生成,inOrderTraverse函数可以省略掉。下面这段是我一开始的解法:#include#include#includeintN,root;std::vectorpreorder,postorder,left,right;std::mapmp;boolflag=true;boolff=true;intbuild(intpreL,intp
天天AZ
·
2023-06-09 06:46
PAT甲级
pat考试
1118 Birds in Forest (
PAT甲级
)
#include#includeconstintMAXN=10001;intN,K,t,tmp,sz,cnt,Q,u,v;intfather[MAXN];std::setst;intfindFather(inti){inta;intx=i;while(father[i]!=i){i=father[i];}while(x!=father[x]){a=x;x=father[x];father[a]=i
天天AZ
·
2023-06-09 06:46
PAT甲级
算法
pat考试
1114 Family Property (
PAT甲级
)
#include#include#include#include#includeconstintMAXN=10000;structnode{intid;intmemberNbr=1;intsetNbr;intarea;node(int_id,int_setNbr,int_area):id(_id),setNbr(_setNbr),area(_area){}};intN,id,father,moth
天天AZ
·
2023-06-09 06:46
PAT甲级
算法
c++
pat考试
1139 First Contact (
PAT甲级
)
这道题柳婼有个很巧妙的方法,就是如果a和b是朋友(a,b都是四位数字id),那就把a*10000+b和b*10000+a都map到1,那就很容易判断两个人是否朋友了。#include#include#include#include#include#includeconstintMAXN=10000;intN,M,K,a,b,u,v;std::strings1,s2,src,dst;std::set
天天AZ
·
2023-06-09 06:16
PAT甲级
c++
算法
数据结构
pat考试
1098 Insertion or Heap Sort (
PAT甲级
)
1098.InsertionorHeapSort(25)-
PAT甲级
真题(堆排序)_柳婼的博客-CSDN博客已经根据柳婼的解法改进了一些,但她的代码还是简洁不少。
天天AZ
·
2023-06-09 06:43
PAT甲级
pat考试
上一页
2
3
4
5
6
7
8
9
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他