杭电HDU
Sensente
满船清梦压星河
展开
-
HDU2157 How many ways??(可达矩阵+矩阵快速幂)
http://acm.hdu.edu.cn/showproblem.php?pid=2157题目大意:不多赘述。关键是知道题目如何解决。其实其求的就是可达矩阵(不懂的参看离散数学图论)在实际系统建模工程中,有向图D={S,R}中,对于Si,Sj 属于S,如果从Si到Sj有任何一条通路存在,则可称Si可达Sj。利用布尔矩阵的运算性质给出了计算有向图可达矩阵的方法,该方法计算简...原创 2019-11-25 10:59:35 · 368 阅读 · 0 评论 -
杭电1097 A Hard Puzzle(快速幂)
杭电1097http://acm.hdu.edu.cn/showproblem.php?pid=1097题目大意:求a的b次方的尾数。快速幂。中间取模即可。AC代码:#include <iostream>#include <cstring>#include <algorithm>#include <stdlib....原创 2019-05-10 18:29:00 · 131 阅读 · 0 评论 -
杭电1286 找新朋友(欧拉函数)
杭电1286http://acm.hdu.edu.cn/showproblem.php?pid=1286题目大意:求出1~N范围内与N互质数的个数。即欧拉函数。AC代码:#include <iostream>#include <cstring>#include <algorithm>#include <stdlib.h>...原创 2019-05-10 18:09:19 · 145 阅读 · 0 评论 -
杭电1283 最简单的计算机
杭电1283http://acm.hdu.edu.cn/showproblem.php?pid=1283题目大意:阅读理解。AC代码:#include<iostream>#include<cstring>using namespace std;char a[205];int m1,m2;int r1,r2,r3;int main() ...原创 2019-05-10 17:45:54 · 121 阅读 · 0 评论 -
杭电3501 Calculation 2(欧拉函数)
杭电3501http://acm.hdu.edu.cn/showproblem.php?pid=3501题目大意:求1~N中与N互质的数之和与1~N之和的差值。欧拉公式拓展:欧拉公式:(性质4)AC代码:#include <iostream>#include <cstring>#include <algorith...原创 2019-04-24 23:17:42 · 250 阅读 · 0 评论 -
杭电1232 畅通工程
杭电1232 畅通工程http://acm.hdu.edu.cn/showproblem.php?pid=1232问题描述:并查集。B站有卿学姐的讲解并查集视频,请自行搜索。该题只要写出并查集,然后依次判断是否连通即可。AC代码:#include <iostream>#include <cstring>#include <a...原创 2019-04-24 22:42:43 · 190 阅读 · 0 评论 -
杭电1170 Balloon Comes!
杭电1170http://acm.hdu.edu.cn/showproblem.php?pid=1170题目大意:有点像逆波兰表达式。但是要简单的多。注意:像 / 1 2 这样的输入 应该输出 0.50(保留两位) 而 "/ 2 1" 则是2(无小数保留)。AC代码:#include <iostream>#include <stdio.h...原创 2019-05-04 02:29:27 · 212 阅读 · 0 评论 -
杭电1200 To and Fro
杭电1200http://acm.hdu.edu.cn/showproblem.php?pid=1200题目大意:矩阵字符串处理。AC代码:#include <iostream>#include <cstring>#include <algorithm>#include <memory.h>#include...原创 2019-05-04 01:27:18 · 189 阅读 · 0 评论 -
杭电1009 FatMouse's Trade
杭电1009http://acm.hdu.edu.cn/showproblem.php?pid=1009题目大意:一只肥鼠一开始有M个猫粮,经过N个房间。在每个房间,它可以用F[i]*a%的猫粮去换取J[i]*a%的鼠粮。由于物品可分割,不能使用背包。直接贪心,用结构体构造,按照Rate = f / j 这样的最大比例去排序,依次拾取即可。AC代码:...原创 2019-05-03 21:45:19 · 188 阅读 · 0 评论 -
杭电1163 eddy's Digital Roots
杭电1163http://acm.hdu.edu.cn/showproblem.php?pid=1163题目大意:求n^n的数根(同九余数定理)AC代码:#include <iostream>#include <stdio.h>#include <cstring>#include <algorithm>#...原创 2019-05-03 21:02:15 · 157 阅读 · 0 评论 -
杭电1013 Digital Roots(九余数定理)
杭电1013http://acm.hdu.edu.cn/showproblem.php?pid=1013题目大意:所谓数根。即数字各个位置之和。若和大于10,则需要再次求和,直到小于10.AC代码:#include <iostream>#include <cstring>#include <algorithm>#in...原创 2019-05-03 20:26:12 · 201 阅读 · 0 评论 -
杭电1106 排序(字符串分割)
杭电1106http://acm.hdu.edu.cn/showproblem.php?pid=1106题目大意:给定一串字符串,以字符串中的‘5’为分割,且去除前导0后按从小到大顺序输出。题目思路:对于每个以5为分割的字符串数字大小,可以以b[i]*10 + (a[i] - '0')计算得到。即每进一位*10;而对于分割的字符串,要分情况,第一种是遇到5,且前置一个字符不...原创 2019-04-23 23:27:31 · 238 阅读 · 0 评论 -
杭电1108 最小公倍数
杭电1108http://acm.hdu.edu.cn/showproblem.php?pid=1108题目大意:没啥好说的。两数乘积除以GCD即可。AC代码:#include <iostream>#include <cstring>#include <algorithm>#include <stdlib.h>...原创 2019-04-25 22:32:35 · 180 阅读 · 0 评论 -
杭电2075 A|B?
杭电2075 http://acm.hdu.edu.cn/showproblem.php?pid=2075 题目大意:以为会超时或者有其他的。。。实际上什么都没有。。 AC代码:#include <iostream>using namespace std;long long a,b;int n;int main() { while(cin&...原创 2019-02-12 22:58:30 · 168 阅读 · 0 评论 -
杭电1002 A + B Problem II(字符串+详细解答!!!)
杭电1002http://acm.hdu.edu.cn/showproblem.php?pid=1002题目大意:大数相加。思路 :用字符串模拟,每次从后往前同位相加,结果大于等于10 前位进一。考虑三种情况:一、a串长度大于b串。二、b串长度大于a串。三、a、b串长度相等。对于第一、二种情况。我们需要将两串字符串进行对齐处理。即用长度较短的字符串去对齐长...原创 2019-05-12 00:14:19 · 374 阅读 · 0 评论 -
杭电1720 A+B Coming
杭电1720http://acm.hdu.edu.cn/showproblem.php?pid=1720水题爽一爽。十六进制的话,直接格式化输入,输出即可。#include <iostream>#include <stdio.h>#include <cstring>#include <algorithm>#include &l...原创 2019-05-21 00:14:45 · 147 阅读 · 0 评论 -
杭电1287 破译密码(异或)
杭电1287http://acm.hdu.edu.cn/showproblem.php?pid=1287题目大意:认真读题。。。用一个大写字母异或原文得到密文解决思路:异或运算性质:这里用到了异或运算的自反性。A XOR B = CB即为所求秘钥A XOR B XOR A = C XOR A = B所以依次枚举大写字母,直到所有的密文都可以被解密成大写字母即可...原创 2019-05-12 01:03:28 · 200 阅读 · 0 评论 -
杭电2795 Billboard(线段树)
HDU2795http://acm.hdu.edu.cn/showproblem.php?pid=2795BillboardTime Limit: 20000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 32859 Accepted Submissi...原创 2019-09-15 00:02:15 · 165 阅读 · 0 评论 -
杭电1166 敌兵布阵(线段树)
HDU1166http://acm.hdu.edu.cn/showproblem.php?pid=1166敌兵布阵Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 153319 Accepted Submission(s):...原创 2019-09-14 16:20:26 · 165 阅读 · 0 评论 -
杭电4993 Revenge of ex-Euclid
http://acm.hdu.edu.cn/showproblem.php?pid=4993Revenge of ex-EuclidTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1093 Accepted Submissi...原创 2019-09-04 19:54:57 · 162 阅读 · 0 评论 -
杭电2161 Primes
HDU2161http://acm.hdu.edu.cn/showproblem.php?pid=2161AC代码:#include <iostream>using namespace std;bool prime(int x) { if(x == 1 || x == 2) return false; for(int i = 2; i * i ...原创 2019-07-15 10:50:35 · 179 阅读 · 0 评论 -
杭电1029 Ignatius and the Princess IV
杭电1029http://acm.hdu.edu.cn/showproblem.php?pid=1029题目大意:求一组数中正好出现了(n + 1) / 2次的数字。解题思路:一开始看错了。。以为求最大的那个呢。AC代码:#include <iostream>#include <algorithm>using namespace std;...原创 2019-06-23 20:39:42 · 99 阅读 · 0 评论 -
杭电1012 u Calculate e
HDU1012http://acm.hdu.edu.cn/showproblem.php?pid=1012题目大意:直接打印解题思路:没什么好说的。。。甚至可以直接打表AC代码:#include <iostream>#include <cstring>using namespace std;const int maxn = 1e4 + 5...原创 2019-06-23 20:23:33 · 113 阅读 · 0 评论 -
杭电1018 Big Number
HDU1018http://acm.hdu.edu.cn/showproblem.php?pid=1018题目大意:求n的阶乘的位数解题思路:首先了解如何求算一个数字的位数,其实很简单。即digit(n) = ceil(log(n) / log(10)); //这里的log是内置函数而阶乘恰好可以与对数运算结合成加法。即将从1 到 n的每个数字都算出位数后...原创 2019-06-23 17:40:28 · 136 阅读 · 0 评论 -
杭电6543 Can you raed it croretcly?
HDU 6543http://acm.hdu.edu.cn/showproblem.php?pid=6543题目大意:判断两字符串,要是相等就Equal 否则第一位和最后一位相等且所用字符全部相同就输出Yes 其余情况全部输出NOAC代码:#include<iostream>#include<cmath>#include <cstri...原创 2019-06-10 15:20:49 · 251 阅读 · 0 评论 -
杭电1030 Delta-wave
杭电1030 http://acm.hdu.edu.cn/showproblem.php?pid=1030AC代码:#include<iostream>#include<cmath>using namespace std;const int MAXN = 1e5 + 10;int a[MAXN],t[MAXN],b[MAXN];int n,m...原创 2019-06-09 09:34:22 · 158 阅读 · 0 评论 -
杭电1801 Annoying painting tool(贪心)
杭电1801http://acm.hdu.edu.cn/showproblem.php?pid=1801题目大意: 给定n * m 的矩阵范围,每次可以将 r * c 的矩阵变换颜色。问能否变成给定的矩阵颜色,如果可以就输出需要变换的次数,否则输出-1.解题思路:贪心,每次从上到下,从左到右的改变范围内矩阵的颜色,最后与目标矩阵作比较。注意:输入采用的是字符串形式...原创 2019-05-26 23:08:57 · 131 阅读 · 0 评论 -
杭电6510 Problem K. Harbin Sausage
杭电6510http://acm.hdu.edu.cn/showproblem.php?pid=6510题目大意:求圆柱体体积。注意:中间存在/运算,不能在中间进行,而是统一进行。PE提示:输出无换行。AC代码:#include <iostream>#include <cstring>#include <algorithm>...原创 2019-05-12 18:37:02 · 236 阅读 · 0 评论 -
杭电6500(2018 东北地区大学生程序设计竞赛)Problem A. Game with string
杭电 6500Problem A. Game with string题目大意:奇奇怪怪的题目。AC代码:#include <iostream>#include <cstring>#include <algorithm>#include <stdlib.h>#include <cmath>#include &...原创 2019-05-12 18:20:47 · 394 阅读 · 0 评论 -
杭电2061 Treasure the new start, freshmen!
杭电2061 http://acm.hdu.edu.cn/showproblem.php?pid=2061 题目大意:分别给出一些课程的学分与成绩,要求每门课学分*成绩的总和除去 总分学和。若有任何一门课挂科,即小于60分则不存在GPA。 这题目总给我报输出超限。 #include <iostream>#include <cstring&g...原创 2019-02-12 22:52:39 · 230 阅读 · 0 评论 -
杭电2060 Snooker
杭电2060 http://acm.hdu.edu.cn/showproblem.php?pid=2060 题目大意:两个人比赛斯诺克,若有红球,先打红球,打进红球后可击打彩球,当然为了保证最大化得分,打黑球。这样一轮可以得到8分。打完红球后,才可以击打彩球。题目中有一块描述不清,"they are not get out of the hole"事实上在红球没打完之前击打...原创 2019-02-12 16:43:25 · 573 阅读 · 0 评论 -
杭电2033 人见人爱A+B
杭电 2033 http://acm.hdu.edu.cn/showproblem.php?pid=2033 题目大意:时间进制转换。而且就两组时间。。一开始看成N组时间了。。两组时间的话直接相加,分,秒>=60进位同时自身-60即可。 #include <iostream>#include <algorithm>#include &...原创 2019-02-03 17:14:50 · 200 阅读 · 0 评论 -
杭电2020 绝对值排序 (绝对值+冒泡排序)
杭电2020 http://acm.hdu.edu.cn/showproblem.php?pid=2020 题目大意:普通排序+绝对值,在数组下标加上abs比较即可,用冒泡排序保证输出结果。 AC代码:#include <iostream>#include <algorithm>#include <cmath>using...原创 2019-02-03 11:56:25 · 351 阅读 · 0 评论 -
杭电2046 骨牌铺方格
杭电2046 http://acm.hdu.edu.cn/showproblem.php?pid=2046 题目大意:2*n的矩形用2*1的矩形去铺满。若第一列矩形竖着放置 则有a[n-1]种若第一、二行横放 则有a[n-2] 种递推式: a[n]=a[n-1]+a[n-2]类似斐波那契数列 AC代码:#include <iostream>...原创 2019-02-14 16:32:45 · 176 阅读 · 0 评论 -
杭电2083 简易版之最短距离
杭电 2083 http://acm.hdu.edu.cn/showproblem.php?pid=2083 题目大意很水。。一维线性求一点到各点距离最短。很明显是中值点。。sort后向上取整(ceil) 然后分别由各点差值绝对值相加即可。 AC代码:#include <iostream>#include <algorithm>#...原创 2019-02-02 23:03:43 · 379 阅读 · 0 评论 -
杭电 2068 RPG的错排 (组合数+错排公式)
杭电2068 RPG的错排http://acm.hdu.edu.cn/showproblem.php?pid=2068 听题目名字也知道,这题和错排公式肯定有关。仔细阅读以下题目意思。猜对一半人即算正确。即保证n/2个人错排即可。同时是选择i/n 的i个人进行错排,所以需要再用组合数C进行选择。而组合数C的实现也是本题的点之一。 AC代码:#incl...原创 2019-02-01 20:16:07 · 263 阅读 · 0 评论 -
杭电2021 发工资咯:)
杭电2021http://acm.hdu.edu.cn/showproblem.php?pid=2021发工资咯:)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 78314 Accepted Submission(s): 4...原创 2018-10-13 11:49:10 · 401 阅读 · 0 评论 -
杭电2015 偶数求和
杭电2015 偶数求和http://acm.hdu.edu.cn/showproblem.php?pid=2015 题目大意:很好理解,不再赘述。比较水,但是有些小点,尤其是行末空格需要控制好。思路:用一个cnt记录目前处理的数据个数,达到M即输出平均数并且清零就完事儿了。当然也可以用整体的数字取模。这个就没尝试了。 AC代码:#include <i...原创 2019-01-26 22:58:25 · 543 阅读 · 0 评论 -
杭电2036 改革春风吹满地
好名字。题目:http://acm.hdu.edu.cn/showproblem.php?pid=2036题目大意:即求任意多边形的面积。下面这篇博客写的很好:https://blog.csdn.net/sun_shine_/article/details/18799739(需要一点点的线性代数知识) 面积公式:AC代码:#include <...原创 2019-01-26 17:33:25 · 258 阅读 · 0 评论 -
杭电2010 水仙花数
杭电2010http://acm.hdu.edu.cn/showproblem.php?pid=2010水仙花数Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 250531 Accepted Submission(s): 70...原创 2018-10-26 23:55:20 · 294 阅读 · 0 评论