- 博客(37)
- 资源 (1)
- 收藏
- 关注
原创 POJ 2387 Til the Cows Come Home (dijkstra求最短路径)
Til the Cows Come HomeBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get back as quickly as possibleFarme
2020-07-16 22:46:07
138
原创 HDU 1008 Elevator(模拟)
ElevatorThe 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 seconds to move the elevator up one floor, and 4
2020-07-12 22:31:28
133
原创 HDU 1005 Number Sequence(周期性循环 AC题目)
Number SequenceA number sequence is defined as followsf(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7Given A, B, and n, you are to calculate the value of f(n).InputThe input consists of multiple test cases. Each test case contains 3
2020-07-12 20:18:12
199
原创 HDU 1001 Sum Problem (累加和)
Sum ProblemHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge)In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + … + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output
2020-07-12 18:58:11
154
原创 HDU 1753 大明A+B(进阶版大整数加法)
大明A+B话说,经过了漫长的一个多月,小明已经成长了许多,所以他改了一个名字叫“大明”。这时他已经不是那个只会做100以内加法的那个“小明”了,现在他甚至会任意长度的正小数的加法现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。Input本题目包含多组测试数据,请处理到文件结束。每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。Output请在一行里面输出输出A+B的值,请输出最简形式。详细要求请见Sample Output。Sample Inpu
2020-07-12 11:01:06
134
原创 计蒜客 T1389 检验身份证(题解)
检验身份证一个合法的身份证号码由17位地区、日期编号和顺序编号加1位校验码组成。校验码的计算规则如下首先对前17位数字加权求和,权重分配为:{777,999,101010,555,888,444,222,111,666,333,777,999,101010,555,888,444,242424};然后将计算的和对11取模得到值Z;最后按照以下关系对应Z值与校验码M的值Z:0 1 2 3 4 5 6 7 8 9 10M:1 0 X 9 8 7 6 5 4 3 2现在给定一些身份证号码,请你验证校验
2020-07-11 22:22:32
345
1
原创 HDU 1282 回文数猜想(题解)
回文数猜想一个正整数,如果从左向右读(称之为正序数)和从右向左读(称之为倒序数)是一样的,这样的数就叫回文数。任取一个正整数,如果不是回文数,将该数与他的倒序数相加,若其和不是回文数,则重复上述步骤,一直到获得回文数为止。例如:68变成154(68+86),再变成605(154+451),最后变成1111(605+506),而1111是回文数。于是有数学家提出一个猜想:不论开始是什么正整数,在经过有限次正序数和倒序数相加的步骤后,都会得到一个回文数。至今为止还不知道这个猜想是对还是错。现在请你编程序验证
2020-07-11 21:07:08
379
原创 POJ 3438 Look and Say (字符串)
Look and SayThe look and say sequence is defined as follows. Start with any string of digits as the first element in the sequence. Each subsequent element is defined from the previous one by “verbally” describing the previous element. For example, the st
2020-07-11 16:53:09
123
原创 UVA 119 Greedy Gift Givers (简单题)
Greedy Gift GiversThis problem involves determining, for a group of gift-giving friends, how much more each person givesthan they receive (and vice versa for those that view gift-giving with cynicism).In this problem each person sets aside some money f
2020-07-11 15:57:28
240
原创 HDU 1004 Let the Balloon Rise (map的使用,STL)
Let the Balloon RiseContest 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 the contest is over, they will count the balloons of each color and
2020-07-11 09:55:20
108
原创 HDU 2714 ISBN (有点小坑)
ISBNFarmer John’s cows enjoy reading books, and FJ has discovered that his cows produce more milk when they read books of a somewhat intellectual nature. He decides to update the barn library to replace all of the cheap romance novels with textbooks on a
2020-07-10 22:27:23
131
原创 FZU 1056 扫雷游戏(模拟题)
扫雷游戏扫雷是Windows自带的游戏。游戏的目标是尽快找到雷区中的所有地雷,而不许踩到地雷。如果方块上的是地雷,将输掉游戏。如果方块上出现数字,则表示在其周围的八个方块中共有多少颗地雷你的任务是在已知地雷出现位置的情况下,得到各个方块中的数据…… “ * ”表示有地雷.… “.”表示无…经过处理应得到10022101101110Input输入有多组数据,每组数据的第一行有两个数字,m,n(0<m,n<100)表示游戏中雷区的范围为m×n。接下
2020-07-10 19:28:42
498
原创 POJ 2251 Dungeon Master(BFS 广度优先搜索)
Dungeon MasterYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot mov
2020-07-10 16:18:41
129
原创 POJ 1321棋盘问题 (dfs)
棋盘问题在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n当为-1 -1时表示输入结束。随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域,
2020-07-10 08:39:27
690
原创 PAT (Advanced Level) Practice 1009 Product of Polynomials(暴力循环)
题目链接Product of Polynomials这个其实就是一个多项式的相乘,做两层for循环就可以了。AC代码#include <stdio.h>int main(){ int k1, k2, b1[11], b2[11], cnt = 0; double c[2002] = {0}, a1[11], a2[11]; scanf("%d", &k1); for(int i = 0; i < k1; i++) scanf("%d %lf", &b1[i
2020-07-09 20:46:26
132
原创 PAT (Advanced Level) Practice 1008 Elevator(模拟题)
ElevatorThe 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 seconds to move the elevator up one floor, and 4
2020-07-09 16:53:14
129
原创 PAT (Advanced Level) Practice 1007 Maximum Subsequence Sum(极短代码,O(n) 解决)
1007 Maximum Subsequence Sum题意: 求一串数字的最大连续和,并且输出最左端的数字和最右端的数字。这个题可以用一个for循环解决,时间复杂度O(n)。主要是先设置两个端点i,j,i为左端点,j为右端点。如图所示:-101234-5-2337-21i 和 j 开始都从数组下标0开始,然后用sum += a[ j ];如果发现sum < 0,i = j + 1, 继续循环(每次循环 j++),(因为sum > 0,不管怎样,往后加,都
2020-07-09 16:21:06
125
原创 PAT (Advanced Level) Practice 1006 Sign In and Sign Out(性能高,方法简单,直接模拟)
Sign In and Sign OutAt 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, you are supposed to find the ones who
2020-07-09 13:24:29
145
原创 PAT (Advanced Level) Practice 1005 Spell It Right(简单的字符串处理)
Spell It RightGiven a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Specification InputEach input file contains one test case. Each case occupies one line which contains a
2020-07-09 12:50:04
170
1
原创 PAT (Advanced Level) Practice 1004 Counting Leaves(dfs 建立树)
Counting LeavesA family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input SpecificationEach input file contains one test case. Each case starts with a line containing 0<N<100, t
2020-07-09 12:01:26
137
原创 PAT(Advanced Level)Practice 1003 Emergency(迪杰斯特拉求最短路径,纯C实现)
EmergencyAs an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities
2020-07-09 10:02:45
175
原创 HDU 1002 A + B Problem II(高精度加法,C语言解决)
A + B Problem III have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines foll
2020-07-08 23:00:19
185
原创 HDU 1098 Ignatius‘s puzzle(数学推导,一层循环解决)
Ignatius’s puzzleIgnatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5x^13+13x^5+kax,input a nonegative integer k(k<10000),to find the minimal nonegative integer a,make
2020-07-08 17:53:03
179
原创 HDU 1097 A hard puzzle (快速幂运算 取模)
A hard puzzlelcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.this puzzle describes that: gave a and b,how to know the a^b’s
2020-07-08 16:04:47
92
原创 HDU 1172 猜数字(暴力 + 模拟 == 简洁代码)
猜数字keke最喜欢的游戏之一就是猜数字。计算机会随机生成一个四位数,玩家需要猜这个四位数。每猜一个数,计算机都会告诉玩家猜对几个数字,其中有几个数字在正确的位置上。比如计算机随机产生的数字为1122。如果玩家猜1234,因为1,2这两个数字同时存在于这两个数中,而且1在这两个数中的位置是相同的,所以计算机会告诉玩家猜对了2个数字,其中一个在正确的位置。如果玩家猜1111,那么计算机会告诉他猜对2个数字,有2个在正确的位置。现在给你一段keke与计算机的对话过程,你的任务是根据这段对话确定这个四位数
2020-07-08 11:52:01
248
原创 POJ 3006 Dirichlet‘s Theorem on Arithmetic Progressions(又双叒叕是素数筛)
Dirichlet’s Theorem on Arithmetic ProgressionsIf a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing by d, i.e., a, a + d, a + 2d, a + 3d, a + 4d, …, contains infinitely many prime numbers. This fact is
2020-07-08 08:20:41
154
原创 POJ 1019 Number Sequence(数学技巧轻松解决)
Number SequenceA single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2…Sk. Each group Sk consists of a sequence of positive integer numbers ranging from 1 to k, written one a
2020-07-07 21:38:00
557
1
原创 POJ 2136 Vertical Histogram(实属水题)
Vertical HistogramWrite a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the input file and print a vertical histogram that shows how many times each letter (but not blanks, digi
2020-07-07 16:42:37
132
原创 HDU 1304 A Contesting Decision(结构体的简单应用)
A Contesting DecisionJudging a programming contest is hard work, with demanding contestants, tedious decisions, and monotonous work. Not to mention the nutritional problems of spending 12 hours with only donuts, pizza, and soda for food. Still, it can be
2020-07-07 11:01:27
185
原创 OpenJ_Bailian - 3711 字符串移位包含问题(模拟 + 简单解法)
字符串移位包含问题对于一个字符串来说,定义一次循环移位操作为:将字符串的第一个字符移动到末尾形成新的字符串。给定两个字符串s1和s2,要求判定其中一个字符串是否是另一字符串通过若干次循环移位后的新字符串的子串。例如CDAA是由AABCD两次移位后产生的新串BCDAA的子串,而ABCD与ACBD则不能通过多次移位来得到其中一个字符串是新串的子串。Input一行,包含两个字符串,中间由单个空格隔开。字符串只包含字母和数字,长度不超过30。Output如果一个字符串是另一字符串通.
2020-07-05 16:26:39
480
原创 HDU 3233 Download Manager (超级简单的方法)
Download ManagerJiajia downloads a lot, a lot more than you can even imagine. Some say that he starts downloading up to 20,000 files together. If 20,000 files try to share a limited bandwidth then it will be a big hazard and no files will be downloaded.
2020-07-05 09:39:31
1093
原创 HDU 1016 Prime Ring Problem(深搜+回溯+剪枝+Eratosthenes素数筛)
Prime Ring ProblemA ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of first circle should always be 1.In.
2020-07-04 22:25:58
135
原创 HDU 1013 Digital Roots(九余数定理 + 暴力解法)
Digital RootsThe 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 resulting value contains two or more digits, those digits are summed.
2020-07-04 17:53:28
237
原创 HDU 1018 Big Number(简单数学解法无需高精度)
Big NumberIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in t.
2020-07-04 15:32:33
302
原创 HDU1048 The Hardest Problem Ever(AC代码 + scanf小技巧)
题目朱利叶斯凯撒生活在危险和阴谋的时代。凯撒所面临的最艰难的局面就是让自己活着。为了让他活下来,他决定创造第一个密码之一。这个密码是如此令人难以置信的声音,没有人能够在不知道它是如何工作的情况下解决它。你是凯撒军队的副队长。你的工作是破译凯撒发送的信息并提供给你的将军。代码很简单。对于明文消息中的每个字母,您将其向右移动五个位置以创建安全消息(即,如果字母为“A”,则密文将为“F”)。既然你要用凯撒的信息创建纯文本,你就会做相反的事情:密文A B C D E F G H I J K L M N.
2020-07-04 09:28:53
288
原创 POJ2739 Sum of Consecutive Prime Numbers(AC代码 + 详解)
Sum of Consecutive Prime NumbersSome positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations 5 + 7 + 1.
2020-07-03 20:59:23
248
原创 线性筛法求素数
首先介绍最常见的求素数的方法,两层循环暴力求解,时间复杂度O(n^2),数据量大的时候这种方法不可取,代码如下:#include <iostream>using namespace std;int main(){ int i, j, prime[1005]; for(i = 2; i < 1000; i++) { prime[i] = 0; for(j = 2; j < i; j++) //这里的i可改进为sqrt(i) { if(i % j.
2020-07-03 00:07:06
399
1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人