自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 1074 Reversing Linked List (25分)

前面是算法笔记的代码,比较繁琐,后两种是网上找的,放在这里日后对比学习一下。#include<iostream>#include<algorithm>using namespace std;const int maxn = 100010;struct Node { //定义静态链表 int address; int data; int next; int order;}node[maxn];bool cmp(Node a, Node b) { re

2020-05-30 16:23:46 128

原创 宏的调用

C语言学习-翁凯老师C语言#define TOUPPER(c) ('a'<=(c)&&(c)<='z'?(c)-'a'+'A':(c))设s是一个足够大的字符数组,i是int型变量,则以下代码段的输出是:strcpy(s, "abcd");i = 0;putchar(TOUPPER(s[++i]));putchar(TOUPPER(s[++i]));宏展zhidao开的结果是:putchar((‘a’<=(s[++i])&&(s[++i

2020-05-18 15:31:30 709 1

原创 1051 Pop Sequence (25分)

Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the...

2020-02-24 12:07:23 85

原创 计算中缀表达式的值

输入:当一行中只有0 时输入结束,相应结果不输出。分两步,一是将中缀转后缀,而是计算后缀表达式。#include <iostream>#include <cstdio>#include <string>#include <stack>#include <queue>#include <map>using nam...

2020-02-24 11:17:21 243

原创 ★★★1022 Digital Library (30分)

A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number a...

2020-02-23 20:44:33 87

原创 1071 Speech Patterns (25分)

People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while others may prefer “the cops”. Analyzing such patterns can help to narrow down a speaker...

2020-02-23 16:45:41 65

原创 1054 The Dominant Color (20分)

Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the d...

2020-02-23 15:58:21 56

原创 1100 Mars Numbers (20分)

People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, re...

2020-02-23 14:09:48 59

原创 1060 Are They Equal (25分)

If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×10^5 ​with simple chopping. Now given the number of signifi...

2020-02-23 11:25:27 77

原创 1063 Set Similarity (25分)

Given two sets of integers, the similarity of the sets is defined to beN​c​​/N​t​​×100%, where N​c ​​is the number of distinct common numbers shared by the two sets, and Nt ​​is the total number of d...

2020-02-23 09:14:07 63

原创 1039 Course List for Student (25分) && 1047 Student List for Course (25分)

Input Specification:Each input file contains one test case. For each case, the first line contains 2 positive integers: N (≤40,000), the number of students who look for their course lists, and K (≤2,...

2020-02-22 22:23:59 112

原创 B1017 A除以B、A10231023 Have Fun with Numbers、1024 Palindromic Number以及高精度的四则运算

#include<stdio.h>#include<string.h>#include<algorithm>using namespace std; struct bign { int d[1000]; int len; bign() { //构造函数,用于初始化结构体 memset(d, 0, sizeof(d)); len = 0;...

2020-02-22 17:23:56 81

原创 1096 Consecutive Factors (20分)

Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three consecutive numbers. Now given ...

2020-02-22 14:42:52 66

原创 1059 Prime Factors (25分)

Input Specification:Each input file contains one test case which gives a positive integer N in the range of long int.Output Specification:Factor N in the format N = p​1​​k​1​​*p​2​​k​2​​*…*p​m​​^k​...

2020-02-22 12:02:15 94

原创 1078 Hashing (25分)

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%TSiz...

2020-02-22 09:47:11 76

原创 1015 Reversible Primes (20分)

A reversible prime in any number system is a prime whose “reverse” in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pr...

2020-02-22 08:47:19 58

原创 1007 素数对猜想 (20分)

让我们定义d​n​​为:d​n​​=p​n+1​​−p​n​​,其中p​i​​是第i个素数。显然有d​1​​=1,且对于n>1有d​n​​是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。现给定任意正整数N(<10​次方5​​),请计算不超过N的满足猜想的素数对的个数。输入格式:输入在一行给出正整数N。输出格式:在一行中输出不超过N的满足猜想的素数对的个数。输入...

2020-02-21 22:20:08 52

原创 1034 有理数四则运算 (20分)

本题要求编写程序,计算 2 个有理数的和、差、积、商。输入格式:输入在一行中按照 a1/b1 a2/b2 的格式给出两个分数形式的有理数,其中分子和分母全是整型范围内的整数,负号只可能出现在分子前,分母不为 0。输出格式:分别在 4 行中按照 有理数1 运算符 有理数2 = 结果 的格式顺序输出 2 个有理数的和、差、积、商。注意输出的每个有理数必须是该有理数的最简形式 k a/b,其中 ...

2020-02-21 20:52:43 157

原创 1049 Counting Ones (30分)

The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s i...

2020-02-21 15:47:03 65

原创 1049 数列的片段和 (20分)

给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.3, 0.4 },我们有 (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) (0.4) 这 10 个片段。给定正整数数列,求出全部片...

2020-02-21 14:27:11 84

原创 1019 数字黑洞 (20分)

给定任一个各位数字不完全相同的 4 位正整数,如果我们先把 4 个数字按非递增排序,再按非递减排序,然后用第 1 个数字减第 2 个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的 6174,这个神奇的数字也叫 Kaprekar 常数。例如,我们从6767开始,将得到7766 - 6677 = 10899810 - 0189 = 96219621 - 1269 ...

2020-02-21 13:02:25 81

原创 1003 我要通过! (20分)

“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于 PAT 的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:字符串中必须仅有 P、 A、 T这三种字符,不可以包含其它字符;任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串;如果 aPbTc...

2020-02-21 12:11:10 50

原创 1045 快速排序 (25分)

著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的 N 个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元?例如给定 N=5N = 5N=5, 排列是1、3、2、4、5。则:1 的左边没有元素,右边的元素都比它大,所以它可能是主元;尽管 3 的左边元素都比它小,但其...

2020-02-21 11:20:52 164

原创 1040 有几个PAT (25分)

字符串 APPAPT 中包含了两个单词 PAT,其中第一个 PAT 是第 2 位§,第 4 位(A),第 6 位(T);第二个 PAT 是第 3 位§,第 4 位(A),第 6 位(T)。现给定字符串,问一共可以形成多少个 PAT?输入格式:输入只有一行,包含一个字符串,长度不超过10​5次方​​,只包含 P、A、T 三种字母。输出格式:在一行中输出给定字符串中包含多少个 PAT。由于...

2020-02-21 09:21:16 49

原创 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,...

2020-02-19 16:57:51 164

原创 对于网路层设备在哪一层工作的理解

设备工作在第几层是指最高在第几层工作,设备可以看懂向下层次所传输的内容

2019-08-20 18:56:16 349

原创 PAT B1013 数素数

1013 数素数 (20 分)令 P​i​​ 表示第 i 个素数。现任给两个正整数 M≤N≤10​4​​,请输出 P​M​​ 到 P​N​​ 的所有素数。输入格式:输入在一行中给出 M 和 N,其间以空格分隔。输出格式:输出从 P​M​​ 到 P​N​​ 的所有素数,每 10 个数字占 1 行,其间以空格分隔,但行末不得有多余空格。输入样例:5 27输出样例:11 13 17 1...

2019-01-21 11:30:38 83

原创 100以内的素数

&amp;lt;textarea readonly=&quot;readonly&quot; name=&quot;code&quot; class=&quot;c++&quot;&amp;gt; #include&amp;lt;stdio.h&amp;gt;#include&amp;lt;math.h&amp;gt;bool isPrime(int n) { if(n &amp;lt;=

2019-01-21 10:32:38 383

空空如也

空空如也

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

TA关注的人

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