![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
HDOJ
HFUT_橘生淮南
这个作者很懒,什么都没留下…
展开
-
HDOJ1016 Prime Ring Problem【DFS】
HDOJ1016题目代码#include<iostream>#include<algorithm>#include<cstring>#include<math.h>#include<cstdio>using namespace std;int n;int a[25], book[25];bool judge_p...原创 2020-07-29 21:27:22 · 111 阅读 · 0 评论 -
HDOJ1005 Number Sequence
HDOJ1005题目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(n).Inpu...原创 2019-07-17 21:10:18 · 158 阅读 · 0 评论 -
HDOJ1029 Ignatius and the Princess IV
HDOJ1029题目代码在这里插入代码片原创 2019-08-07 20:14:25 · 145 阅读 · 0 评论 -
HDOJ1032 The 3n + 1 problem
HDOJ1032代码#include <stdio.h>int cycle_length(int n) //求循环长度的函数{ int count = 0; while(n!=1) { if(n%2) { n = 3*n+1; } else ...原创 2019-08-07 20:44:30 · 138 阅读 · 0 评论 -
HDOJ1040 As Easy As A+B(注意输出的问题)
HDOJ1040代码//错误输出while(cin>>N){ for(i=0;i<N;i++) { cin>>count; arr.clear(); for(j=0;j<count;j++) { ...原创 2019-08-07 21:02:35 · 210 阅读 · 0 评论 -
HDOJ1048 The Hardest Problem Ever
HDOJ1048题目代码#include <stdio.h>#include<cstring>#include<string>#include <iostream>using namespace std;int main(){ string str; int i; getline(cin,str); ...原创 2019-08-28 20:55:45 · 121 阅读 · 0 评论 -
HDOJ1058 Humble Numbers【优先队列】
HDOJ1058题目代码思路一:开始我的想法是把某个范围内的数一一测试是否是humble number,是就存进数组里,不是就测试下一个。但这样的代价是时间超了!//超时代码#include <stdio.h>#include <math.h>int judge_humble(int m){ while(m!=1) { ...原创 2019-08-31 21:39:40 · 227 阅读 · 0 评论 -
HDOJ1010 Tempter of the Bone[DFS+奇偶剪枝]
HDOJ1010题目思路一般BFS用于求最短路,想求全部解可以用DFS。因此本题用DFS求解。我根据之前上课老师给的DFS模板直接修改的,改的地方不是很多。1.DFS里return true的条件原本是now等于终点就可以了。现在不仅要等于终点,还要时间上相等2.迷宫表示问题原来0代表可走,1代表不可走。现在.代表可走,X代表不可走代码在这里插入代码片#include &l...原创 2019-09-16 23:04:59 · 143 阅读 · 0 评论 -
HDOJ1015 Safecracker【DFS排列】
HDOJ1015题目思路这道题可以抽象为排列问题。假设有12个字母,要选出5个字母分别代入v-w^2+ x^3 -y^4+ z^5式子里。数学上,这就是一个排列问题,一共有95040种结果。程序上,排列问题可以用dfs解决。代码//数组a表示字母对应的int数值//a[step] = 1表示第step(step范围:1-5)个位置放置的字母是‘A’//book[i] = 0表示字...原创 2019-09-20 00:04:39 · 122 阅读 · 0 评论 -
HDOJ1021 Fibonacci Again【找规律】
HDOJ1021题目思路看到n的范围就知道这题递归应该是不行的。只要找到规律这一题就很简单啦!F(0) = 7 --------- 7%3 = 1F(1) = 11 --------- 11%3 = 2F(2) = 18 --------- 18%3 = 0F(3) = 29 --------- 29%3 = 2F(4) = 47 --------- 47%3...原创 2019-07-20 11:30:07 · 155 阅读 · 0 评论 -
HDOJ1004 Let the Balloon Rise
HDOJ1004题目InputInput contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) – the total number of balloons distributed. The next N lines contain one color each. T...原创 2019-07-17 17:10:49 · 133 阅读 · 0 评论 -
HDOJ1012 u Calculate e
HDOJ1013题目代码#include<stdio.h>int main(){ int n, i; double e = 0.0; int item = 1; printf("n e\n"); printf("- -----------\n"); printf("0 1\n"); printf("1 2\n"); printf("2 2.5\...原创 2019-07-18 16:12:35 · 128 阅读 · 0 评论 -
HDOJ1013 Digital Roots【常规解法+九余数定理】
HDOJ1013题目代码1:常规解法#include<stdio.h>#include<string.h>int main(){ char number[100000]; int sum, m, i, n; while(gets(number)) { sum = 0; for(i=0;i<strlen(number);i++...原创 2019-07-18 17:49:29 · 175 阅读 · 0 评论 -
HDOJ1014 Uniform Generator 【三种解法(暴力+互质)】
HDOJ1014题目思路简单来说,题目的意思是给定STEP和MOD,能够把0到MOD-1的数都产生一次的就是Good Choice,否则就是Bad Choice。1.暴力求解:定义一个seed数组从seed[0]依次往后计算。定义一个布尔型isChange数组,计算出seed[i]的值时,对应的isChange[seed[i]]就记为true。最后如果isChange数组中的值都为true...原创 2019-07-18 20:19:29 · 285 阅读 · 0 评论 -
HDOJ1017 A Mathematical Curiosity【枚举(题目不难却坑啊)】
HDOJ1017题目代码1这种方法是通过floor函数。floor(x)返回不大于x的最大整数,可以利用这个函数判断x是否为整数。#include<stdio.h>#include<math.h>int isInteger(int a, int b, int m) //判断计算结果是否为整数{ double r...原创 2019-07-19 11:03:10 · 154 阅读 · 0 评论 -
HDOJ1000 A + B Problem
HDOJ1000题目Problem DescriptionCalculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1Sample Outp...原创 2019-07-17 10:27:36 · 146 阅读 · 0 评论 -
HDOJ1001 Sum Problem
HDOJ1001题目InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be i...原创 2019-07-17 10:50:16 · 242 阅读 · 0 评论 -
HDOJ1019 Least Common Multiple (求几个数的最小公倍数)
HDOJ1019题目思路1.两个数的最大公约数:辗转相除法(我的代码是用递归实现的)。两个数的最小公倍数:两个数相乘,再除以两个数的最大公约数。2.三个数的最大公约数:先求前两个数的最大公约数,再将结果与第三个数求最大公约数。三个数的最小公倍数:先求前两个数的最小公倍数,再将结果与第三个数求最小公倍数。3.多个数的求法雷同。事实上,求多个数的最小公倍数的问题最终就是求两个最小公倍数...原创 2019-07-19 18:30:32 · 267 阅读 · 0 评论 -
HDOJ1028 Ignatius and the Princess III【母函数(类似的题还有1085、1398)】
HDOJ1028、1085、1398母函数(生成函数)定义:某个序列的母函数是一种形式幂级数,每一项的系数可以提供关于这个序列的信息思想:把组合问题的加法法则和幂级数的乘幂对应起来两个典型例子1、1g、2g、3g、4g砝码各一枚,能称出哪几种重量,每种重量各有几种可能方案?g(x) = (1+x) (1+x^2) (1+x^3) (1+x^4)2、1分、2分、3分的邮票贴出不同数值的...原创 2019-07-29 17:04:46 · 152 阅读 · 0 评论 -
HDOJ1008 Elevator
HDOJ1008题目Problem DescriptionThe 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...原创 2019-07-18 15:39:58 · 148 阅读 · 0 评论