自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

CC

  • 博客(104)
  • 收藏
  • 关注

原创 EOJ 1082. Easy to AC

原题链接思路分析法一:动态规划这个题在dfs标签下,但实际上也可以用其他的方法来写。因为10的阶乘就已经等于3,628,800且大于1,000,000先将0到9的阶乘直接算出保存在数组a里。因为刚好在刷01背包的问题,所以换种思路来实现。使用递归的想法:如果我们遍历处于a[i],和为n时,对于a[i]这个数,我们有两种选择,即选和不选,如果选,那么下一个就是要遍历的位置即为i-1...

2019-03-14 16:35:09 214

原创 EOJ 2848. 华师大卫星照片

原题描述题目分析经典题:求最大连通区域。BFS和DFS皆可实现,不过BFS优于DFS。代码部分/********DFS递归实现*********/#include<bits/stdc++.h>using namespace std;#define N 1001char a[N][N];int n, m;//上下左右移动int go[][2] = { ...

2019-03-13 15:59:36 563

原创 EOJ 1816连通(并查集)

原题链接题目分析题意为判断无向图是否连通 亦等价为 找出无向图的连通分量的个数,如果只有一个连通分量,即该无向图连通。dfs和bfs都能实现,但个人觉得并查集更方便一些。先初始化tree数组,使用fill或者fill_n初始化可以使初始值为任意值,memset更适合初始化为0。注意点是从1到n计算,所以数组初始化要初始化到n+1,这里WA了。并查集具体实现看代码。代码实现...

2019-03-13 11:14:29 259

原创 1029 旧键盘(c++实现)

原题描述思路分析本来想着遍历a字符串,和b字符串依次比较,将不同的字符按要求输出,同时设定一个数组用于记录是否已被输出过,但总有用例不通过…没想明白还有什么用例问题,参考的网上的代码,发现很简单,不用分别判断,一次性判断输出就好。代码#include<bits/stdc++.h>using namespace std;int main(){ stri...

2019-03-07 16:34:05 242 1

原创 1028 人口普查(c++实现)

原题描述题目分析还是排序问题。依然执着地使用string类型来比较大小!噢耶!输入的同时判断日期是否合理,同时比较大小,和数字没啥两样,只是以字符串来实现。详细见代码实现。注意:如果有0个即没有日期合法,那么输出格式会不一样,需要另外输出。代码#include<bits/stdc++.h>using namespace std;int main(){ ...

2019-03-07 10:25:50 666

原创 1027 打印沙漏(c++实现)

原题描述思路分析对于输入的n=1,和n<7可单独处理。对于n>=7,用字符串数组s[100]来存储每一行的字符串。从第三个字符开始存储。用len表示为从第一层(三个字符)到最高层一共有几行。s数组存储每一行的字符串。比如s[0]="***", s[1]="*****"根据逐行递增两个字符串,可知最高层一共有2*len+1个字符,那么整个沙漏一共有2*{len*[3+(2...

2019-03-06 23:00:19 3289

原创 1024 科学计数法(c++实现)

原题描述思路分析用字符串来储存输入的数据,刨开正负号,小数点,E及之后的数据。移位的时候注意要添0,个数及位置。c++中的string类型非常好用!还要熟练一点使用!附上官方文档:官方string类型下各函数使用详细的实现过程见代码。代码实现#include<bits/stdc++.h>using namespace std;int main(){ ...

2019-03-04 15:35:11 1466

原创 1020 月饼(c++实现)

原题描述题目分析算出单价,排序,贪心。注意是double类型。代码部分#include<bits/stdc++.h>using namespace std;struct mooncake{ double store; double price; double unit_price; bool operator < (const...

2019-03-03 20:36:51 1014

原创 1019 数字黑洞(c++实现)

原题描述思路分析为方便排序,以string类型作为读入。因为要做减法,所以还得转换为int型整数,我用的cb显示无法识别to_string函数和stoi函数…但是pat提交是可以的。因为要补齐位数,所以无论输入的是几位数,都要在高位添0以满足于四位数减法。用string类型下的insert函数可以实现。代码部分#include<bits/stdc++.h>usi...

2019-03-03 17:37:27 810

原创 1014 福尔摩斯的约会(c++实现)

题目描述思路分析题目本身并不难,就是要搞清楚所有的判别条件前两个字符串第一对大写字母相等的为对应的星期 (注意此处的大写字母实际只能是A-G)再往后字符相同的输出对应的小时(注意此处的字符可以为数字,当其为字母的时候只能为大写,看题目!!!)接下来的两对字符串相同字符对应的位置即为分钟(这个判断最简单==)代码部分#include<bits/stdc++.h>...

2019-03-02 19:35:55 523

原创 1081 检查密码(c++实现)

题目描述思路分析改了n遍都不知道错在哪,想了半天错误的可能,原来是因为直接cin >> password会没法读入密码中的空格,呵呵。代码部分#include<iostream>#include<cstdio>using namespace std;int main(){ // ios::sync_with_stdio(0); ...

2019-02-26 16:07:59 620 1

原创 1086 就不告诉你(c++实现)

题目描述思路详解一开始思路很简单,倒着输出很直接printf("%d",n - n/10 *10); n/=10;484超简单。。然而并没有这么简单。。因为10*10=100应该输出1而不是001,所以如果最开始一直是0要删掉呀偷懒没用字符串,懒得转嚯嚯嚯,字符串转过来其实也超快!代码如下#include<iostream>#include<cstdi...

2019-02-26 14:55:14 453

原创 1041 考试座位号(c++实现)

题目描述思路分析该题关键在于如何存储这组关联数据,一开始想到用结构体,但又有点大材小用,不然就开数组,一个数组肯定不够,要开俩,后来看到这个答案,二维数组,用试机号码作为存储索引,后续直接输出即可。代码链接#include<iostream>using namespace std;int main(){ int M; cin >> M...

2019-02-25 10:32:38 443

原创 1031 查验身份证(c++实现)

原文题目描述思路分析这么简单的题写了这么久。。。我怕不是有点智障因为要判断是否全部符合,所以要用count统计符合的个数,这里把判断是否为身份证的功能封装成函数isID重头戏就是怎么写这个函数了。由于输入时用字符串类型,所以要转化成数字类型,同时判断是否为数字,如果不是数字直接return掉,如果是数字,则转化为int类型。再根据加权的到z,这里M里的x不好处理,所以统...

2019-02-23 22:06:44 990 2

原创 1016 部分A+B(C++实现)

原题描述思路分析题目本身不难,就是东搞西搞一直没全对,根据输入的值拼凑出PA和PB,再相加就好了,注意长度,当然也可以用字符串。代码#include<iostream>using namespace std;int main(){ long long int A, B, PA = 0, PB = 0; int DA, DB, cnA = 0, cnB= 0; ...

2019-02-23 17:01:35 288

原创 1007 素数对猜想(c++实现)

题目描述思路分析找出不超过 N (≤105\leq10^5≤105)的所有的质数存入数组P。找出所有满足式子Pn+1−Pn=2 P_{n+1}-P_{n} = 2 Pn+1​−Pn​=2的n的个数,输出即可。代码编写#include<iostream>#include<vector>using namespace std;bool sush...

2019-02-23 14:23:29 276

原创 1005 继续(3n+1)猜想(c++实现)

题目描述思路解析开两个数组,a数组用来记录关键字,b数组用来存储前面的数已经覆盖不用继续再判断的数。判断一个数时,先判断b数组中有没有这个数,如果有,直接判断下一个数,如果没有,把这个数存进a数组,然后把这个数在递推过程中产生的数都存进b数组,直到最后一个数。对a数组进行递减排序然后输出。注意格式。升级版思路解析借用c++的vector可直接扩充输入的n,输入一个数,判断一次...

2019-02-22 17:18:21 640

原创 1004 成绩排名 (c++实现)

题目描述思路分析直接一个一个比较就好了代码记录#include<iostream>#include<string>using namespace std;int main(){ int n = 0; cin >> n; string max_name = "", min_name = "", max_id = "", min_..

2019-02-22 16:14:45 1391

原创 1003 我要通过!(c++实现)

题目链接代码思路详见博客思路解析这道题是根据题目所给条件来找出其隐藏的数学规律当然这里还没有涉及到太过复杂的数学公式,只是找出其变量关系第一个条件很显然就是直接判断,并且可以一开始直接判断,省去部分时间。第二第三个条件可以综合起来观察,而这个观察的结果也就是解决这道题最核心的地方首先PAT符合,若b为空,要符合则a和c必相等以满足xPATx即a = c如果b不为空,判断a...

2019-02-22 15:45:18 1032

原创 1002. 写出这个数(C++实现)

#include<iostream>#include<string>using namespace std;int main(){ string s; cin>>s; int sum = 0; string str[10] = {"ling", "yi", "er", "san", "si", "wu", "liu&qu

2019-02-22 11:07:25 1190

原创 LeetCode&easy 20. Valid Parentheses

题目描述Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same ...

2019-02-02 10:49:07 115

原创 scanf的输入格式

由一道要求用scanf读入包含空格的字符串的题目引来的文scanf 语法:   #include   int scanf( const char *format, ... ); 类似函数有       int scanf(const char *format, ...);       int fscanf(FILE *stream, const char

2017-12-08 21:16:37 21253

原创 1002. A+B for Polynomials

#includeint main ( ){ int i , j , K1 , K2 ; int a , B[1001] ; float A[1001] = {0} , b ; scanf("%d",&K1 ); for ( i = 1 ; i <= K1 ; i++ ) { scanf("%d %f",&a, &b );

2017-11-28 10:56:36 145

原创 1001. A+B Format (20)

恩 刷回PAT。  原题描述如下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

2017-11-28 09:58:00 172

原创 01-复杂度2 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. The Maximum Subsequence is the continu

2017-11-17 21:54:24 296 1

原创 1009.Engima(未解)

原题描述:In World War II, Germany once used an electronic encryption machine called Enigma, which played a decisive role in the initial victories of Nazi Germany. It was proved to be one of the mo

2017-09-12 15:55:16 263

原创 1008.Gnome Tetravex

原题大意:判断相邻的正方形块能否拼成三角形标号相邻的在一起。Hart is engaged in playing an interesting game, Gnome Tetravex, these days. In the game, at the beginning, the player is given n*n squares. Each square is divided into

2017-09-10 14:12:05 346

原创 1007.Numerical Summation of a Series

原题大意就是当x取某个值的时候,求这个公式的值。其实题目下面那个提示已经很明确了,直接求是肯定不行的,可以通过f(x)-f(1)来求f(x) ,因为已知f(1)=1.那么根据公式可以算出 f(x) - f(1) = (1-x) / ( k* (k+1) * (k+x) ) , 这时分母为k的三次方,原题要求的0.5e-12可以只求到10000,减少了运算量。再根据第三个公式求的最后

2017-09-07 10:39:06 436

原创 1006.Do the Untwist

题目大意就是根据字母的序号和给出的公式将密码翻译过来。#include #include int main ( ){ int ciphercode[ 70 ] , plaincode[ 70 ] ; char plaintext[ 70 ] , ciphertext[ 70 ] ; int K ; while ( scanf("%d",&K ) , K )

2017-09-05 17:55:01 303

原创 1005.Jugs

原题 题意 : 就是A B 壶相互倒水,直到B壶的水满足一定数值N 。一开始没搞懂这道题的输出,oj判断的就是得出其中一个解就可以了???好像没啥别的硬性规定,搞得我晕乎了好一阵,直接就一个一个判断数值就好了。代码如下:(要么一直填A ,要么一直填B ,思路是一样的)#include int main( ){ int Ca , Cb , N , a , b ; wh

2017-09-05 16:39:29 232

原创 1002.Fire Net

原题描述:Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall.A blockhouse is a small

2017-08-21 10:10:41 222

原创 1003.Crashing Balloon

原题描述:On every June 1st, the Children's Day, there will be a game named "crashing balloon" on TV.   The rule is very simple.  On the ground there are 100 labeled balloons, with the numbers 1 to 100.

2017-08-21 08:33:40 353

原创 1017.A Mathematical Curiosity

原题描述:Problem DescriptionGiven two integers n and m, count the number of pairs of integers (a,b) such that 0 This problem contains multiple test cases!The first line of a multiple input i

2017-08-19 11:38:01 174

原创 1014.Uniform Generator

原题描述:Problem DescriptionComputer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the formseed(x+1) = [seed(x) + STEP] % MODwhere

2017-08-19 10:43:16 180

原创 1013.Digital Roots

原题描述:Problem DescriptionThe digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the

2017-08-18 10:03:47 815

原创 1012.u Calculate e

原题描述:Problem DescriptionA simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small value

2017-08-18 09:05:39 169

原创 1005.Number Sequence

原题描述:Problem DescriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(

2017-08-17 12:11:48 198

原创 1004.Let the Balloon Rise

原题描述:Problem DescriptionContest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When

2017-08-17 10:25:44 139

原创 1070. 结绳

原题描述:给定一段一段的绳子,你需要把它们串成一条绳。每次串连的时候,是把两段绳子对折,再如下图所示套接在一起。这样得到的绳子又被当成是另一段绳子,可以再次对折去跟另一段绳子串连。每次串连后,原来两段绳子的长度就会减半。给定N段绳子的长度,你需要找出它们能串成的绳子的最大长度。输入格式:每个输入包含1个测试用例。每个测试用例第1行给出正整数N (2 4)

2017-08-15 09:58:53 175

原创 1065. 单身狗

原文描述:“单身狗”是中文对于单身人士的一种爱称。本题请你从上万人的大型派对中找出落单的客人,以便给予特殊关爱。输入格式:输入第一行给出一个正整数N(输出格式:首先第一行输出落单客人的总人数;随后第二行按ID递增顺序列出落单的客人。ID间用1个空格分隔,行的首尾不得有多余空格。输入样例:311111 2222233333 444445555

2017-08-14 17:09:52 191

空空如也

空空如也

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

TA关注的人

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