自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 PAT甲级1060 Are They Equal

想法:这道题坑点多多啊,它可以输入这样的数00123.42,24.42400或000.000。做了这道题,感觉string很强,也发现了一个点,如果string str1没有初始化,那么用已有的str1[0]=str2[0](像字符数组赋值),这样是行不通的,但可以这样str1=str1+str2[0]。自己的代码是根据算法笔记上的测试数据,缝缝补补,感觉很菜。#include<iost...

2019-11-17 14:21:40 91

原创 PAT甲级1059 Prime Factors

想法:这道题要找质因子,所以首先把2到100000左右的质数全找出来,利用素数筛法。经过分析可知,一个数n的质因子要么全小于根号下n,或存在一个大于根号下n的因子,因此可以缩小搜索范围。#include<iostream>#include<queue>#include<malloc.h>#include<cstdio>#include&l...

2019-11-17 10:18:41 152 1

原创 PAT甲级1050 String Subtraction

#include<iostream>#include<queue>#include<malloc.h>#include<cstdio>#include<vector>#include<cstring>using namespace std;int main(){ string s1; stri...

2019-11-14 16:17:57 78

原创 PAT甲级1046 Shortest Distance

超时代码:#include<iostream>#include<queue>#include<malloc.h>#include<cstdio>#include<vector>#include<cstring>using namespace std;int main(){ int n; in...

2019-11-14 15:51:26 79

原创 PAT甲级1042 Shuffling Machine

#include<iostream>#include<queue>#include<malloc.h>#include<cstdio>#include<vector>#include<cstring>using namespace std;int main(){ int n; cin>&...

2019-11-13 11:10:57 76

原创 PAT甲级1041 Be Unique

超时代码(最后两个测试点过不了):#include<iostream>#include<queue>#include<malloc.h>#include<cstdio>#include<vector>using namespace std;int main(){ int n; cin>>n;...

2019-11-11 20:16:20 121

原创 PAT甲级1035 Password

#include<iostream>#include<queue>#include<malloc.h>#include<cstdio>#include<vector>using namespace std;int flag=0;int main(){ int n; char x[1000][11],y[1...

2019-11-10 21:12:55 59

原创 PAT甲级1020 Tree Traversals

想法:刚看到这道题的时候的解题思路是先根据后序和中序遍历(因为根据后序和中序能唯一确定一个二叉树)将二叉树构建出来,然后再利用广度搜索,就能得到二叉树的层次遍历。但构建树的代码写不出来就学习学习别人的。在学习别人的代码的时候,发现了一种不用构建树,更简洁的方法。方法一:创建树的主要思想是,先从后序遍历的最后一个值确定根结点,再根据中序遍历找到根节点,并再对其左子树和右子树进行创建树的操作这样就...

2019-11-09 21:18:10 101

原创 PAT甲级1027 Colors in Mars

想法:主要注意几个点,数据是个位数的情况要补0,还有全部是0的情况。#include<iostream>using namespace std;void solve(int x){ char a[30]; int l=0; if(x==0) cout<<"00"; if(x<13){ while...

2019-11-06 11:25:43 60

原创 PAT甲级1023 Have Fun with Numbers

想法:之前没注意给的数的长度,所以即使用long long int也通过不了最后的三个测试点,这一题要应用大数的加法。#include<iostream>#include<cstring>using namespace std;int main(){ char s[30]; cin>>s; int x[30]; int...

2019-11-05 20:51:54 90

原创 PAT甲级1019 General Palindromic Number

想法:这道题较容易,之前很多道题都有进制的转化。#include<cmath>#include<cstring>using namespace std;int num[100001];int l=0;void turn(int a, int b){ while(a!=0){ num[l]=a%b; a=a/b; ...

2019-11-04 20:59:50 87

原创 PAT甲级1012 The Best Rank

想法:这道题没想出啥更优的方法,就是排序然后查找。第一次提交没注意以下情况:

2019-10-31 14:58:45 97

原创 1011 World Cup Betting

#include<iostream>#include<iomanip>using namespace std;int main(){ double a[3][3]; int n[3]={0}; double max[3]={-1}; double s; for(int i=0; i<3; i++) fo...

2019-10-26 16:56:48 84

原创 PAT1007 Maximum Subsequence Sum

Given a sequence of K integers { N​1​​, N​2​​, …, N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, …, N​j​​ } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence w...

2019-10-22 20:37:26 59

原创 PAT10061006 Sign In and Sign Out

At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in’s and out’s, yo...

2019-10-20 14:56:49 71

原创 PAT1009 Product of Polynomials

想法:这道题是关于多项式的乘法,可以用1002的方法来做。#include<iostream>#include<iomanip>using namespace std;int main(){ double a[1001]={0},b[1001]={0},c[2001]={0},y; int n,m,count=0; int x; ...

2019-10-19 16:21:34 67

原创 PAT甲级1008 Elevator

The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec...

2019-10-19 16:16:48 84

原创 PAT甲级1004 Counting Leaves

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts ...

2019-10-19 16:12:59 82

原创 PAT甲级1002 A+B for Polynomials

1002 A+B for Polynomials (25 分)想法:注意输出格式#include<iostream>#include<iomanip>using namespace std;int main(){ double a[1001]={0}; int n,x,count=0; double y; cin>&g...

2019-10-14 18:14:57 68

原创 PAT甲级1001 A+B Format

1001 A+B Format (20 分)Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specif...

2019-10-14 16:53:03 129

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除