
杭电OJ
KingsCC
这个作者很懒,什么都没留下…
展开
-
杭电2058 求和的顺序子序列
#include<iostream>#include<math.h>using namespace std;void main(){ int n, m; int i, j; while (cin >> n >> m) { if (n == 0 && m == 0) ...转载 2018-08-03 00:43:32 · 249 阅读 · 0 评论 -
杭电2068 错排加组合
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include<string>using namespace std;long long c(int n, int m){ int a = 1; for (int...转载 2018-08-04 01:53:58 · 345 阅读 · 0 评论 -
杭电2061
//不知道为啥不能写成长为51的数组,会爆Runtime Error (ACCESS_VIOLATION)的错 我太菜了 看不出为啥会越界原代码:#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include<string>...原创 2018-08-04 00:54:13 · 305 阅读 · 0 评论 -
杭电2060 斯诺克
读懂题意太难了。。就是每个红球后面可以再打一个彩球,一定是先把红球打完了,貌似黑球掉落到框里是可以再回到桌面上的,其他彩球就不行了,所以两种情况1.大于六个球一定是有红球的,每个红球(1分)后打一个最高分黑球(7分),再把剩下六个彩球打完27分2.小于六个球就只有彩球了,从最高分黑球开始打,全打完就是最后分数了#include <iostream>#include <...转载 2018-08-04 00:09:05 · 568 阅读 · 1 评论 -
杭电2059 龟兔赛跑 动态规划
#include<iostream>#include<math.h>#include<algorithm>using namespace std;void main(){ int l, n, c, t, vr, vt1, vt2,a[110]; double dp[110];//记录到第i个电站的最短时间 double tim...转载 2018-08-03 18:15:59 · 367 阅读 · 0 评论 -
杭电oj 1114 完全背包
#include<iostream>#include<algorithm>using namespace std;#define INF 0x7fffffffstruct mon{ int w; int v;}list[100];void main(){ int dp[100]; int n; int emp; int sum,k;//钱总重...转载 2018-07-15 13:06:06 · 413 阅读 · 0 评论 -
杭电2054 A==B
转自https://www.cnblogs.com/Young-C/p/7748408.html#include <iostream> #include<math.h>#include<cstring>#include<string>using namespace std;string huajian(string m){ //删掉末尾的0 ...转载 2018-07-12 16:18:54 · 376 阅读 · 0 评论 -
杭电2055 easy
#include <iostream>#include<string.h>using namespace std;int f(char c){ int res; if (c >= 'a'&&c <= 'z') res = -(c - 'a' + 1); else if (c >= 'A'&&c...原创 2018-07-12 16:05:28 · 336 阅读 · 0 评论 -
Hdoj 2053(Switch Game)
原理是判断n的因子个数,个数为偶数则是0,为奇数则为1但在各个过程中发现判断因子奇偶数的神奇方法,取决于sqrt的特殊性质向下取整,如果平方根相乘为原整数,则因子个数为奇书数,否则为偶数#include <iostream> #include<math.h>using namespace std;int main(){ int n; while (cin &g...原创 2018-07-11 22:31:18 · 271 阅读 · 0 评论 -
杭电2065
指数生成函数针对在长度不定的序列中可重复选取数列中的元做排列的问题。对指数生成函数的概念介绍https://www.douban.com/note/484814211/思路转载自 http://blog.youkuaiyun.com/ACM_cxlove?viewmode=contents构造指数级生成函数:(1+x/1!+x^2/2!+x^3/3!……)^2*(1+x^2/2!+x^4/4!...转载 2018-08-04 20:27:21 · 881 阅读 · 0 评论 -
杭电2057 十六进制加法
#include<iostream>using namespace std;void main(){ __int64 a, b; while (~scanf("%I64X%I64X", &a, &b)) { if (a + b < 0) printf("-%I64X\n", -(a + b))...转载 2018-08-03 00:17:06 · 577 阅读 · 0 评论 -
杭电2056 矩形相交
#include<iostream>#include<algorithm>using namespace std;void main(){ double x[4],a[4]; double y[4],b[4],s; s = 0; while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x[0], &...转载 2018-08-03 00:09:09 · 315 阅读 · 0 评论 -
杭电 数硬币 暴力/母函数
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include<string>using namespace std;void main(){ int n; while (cin >> n) ...转载 2018-08-05 22:14:32 · 269 阅读 · 0 评论 -
杭电2074 叠框
坑挺多的,首先是n=1的情况要特殊考虑其次是输出格式,气哭我了,它是要求除第一次外输入一行就换行,再输出,我一直是输出后再换行,很窒息我的做法是确定中心,然后确定中间那行,根据中间那行向上、下递推#include <iostream>#include <algorithm>#include <cstdio>#include <cstrin...原创 2018-08-09 22:51:33 · 604 阅读 · 0 评论 -
2073
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include<string>using namespace std;void main(){ int n; while (cin >> n) ...转载 2018-08-09 18:40:55 · 265 阅读 · 0 评论 -
2072 数单词 set
//采用set容器,因为其内容唯一性,可以获得set容器的数目以得到单词数目#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include<string>#include<set>using namespa...转载 2018-08-09 17:05:22 · 271 阅读 · 0 评论 -
杭电oj2052 Picture
#include <iostream> #include<math.h>using namespace std;int main(){ int n, m; char a[76][76]; while (cin >> n>>m) { for (int i = 0; i <= m + 1; i++) ...原创 2018-07-11 15:03:49 · 355 阅读 · 0 评论 -
杭电oj2045 不容易系列之RGB 递推
#include <iostream> using namespace std;//如果第n-1项跟第一项颜色一样,到n-1项是rgb(n-2)种颜色,第n-1项只有1种可能,第n项有两种//所以有rgb(n-2)*2种//如果第n-1项跟第一项颜色不同,则第n项只有1种可能//所以有rgb(n-1)int main(){ int n; long lo...原创 2018-06-29 00:10:10 · 348 阅读 · 0 评论 -
杭电2037
看了下别人的代码,自己想破头也想不到贪心算法,初学贪心算法,感觉这道题还挺典型#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;struct tv{ int l; int r;};bool cmp(tv...转载 2018-06-20 17:20:58 · 241 阅读 · 0 评论 -
杭电2032 杨辉三角
#include <iostream> #include <string> #include<math.h>using namespace std;int main(){ int n; int a[30][30]; while (cin >> n) { for (int i = 0; i < n;...原创 2018-06-18 23:02:59 · 165 阅读 · 0 评论 -
杭电 2031 10进制转n进制
#include <iostream> #include <string> #include<math.h>using namespace std;int main(){ int n,R; while (cin >> n>>R) { int i = 0; int r[100]...原创 2018-06-18 22:37:57 · 215 阅读 · 0 评论 -
杭电2030
一个汉子占两个字节,且每个字节最高位为1 ,判断依据:如果是汉字右移8位应全为1,最后输出的计数除2#include <iostream> #include <string> using namespace std;int main(){ int n,count; char ch[100]; while (cin >> n) { ...原创 2018-06-18 19:57:24 · 348 阅读 · 0 评论 -
杭电OJ2007-2015 C++
2007.注意循环次数和m,n的大小,否则n-m可能是负数。每一次输出后结果要reset#include<iostream>using namespace std;int main(){ int m,n; int sum2=0,sum3=0; int temp; while (cin>>m>>n){ if (m > n...原创 2018-06-10 20:37:39 · 624 阅读 · 0 评论 -
杭电OJ 1000-1002 2000-2005 C++
1000.#include<iostream>using namespace std;int main(){ int a,b; while (cin >> a>>b) { cout << a + b << endl; } return 0;}1002.#include<iostream&g...原创 2018-06-09 22:53:41 · 676 阅读 · 0 评论 -
杭电OJ 1001 C++
#include<iostream>using namespace std;int main(){ int n; while (cin >> n) { if (n%2==0) cout << n/ 2 * (n + 1) << endl << endl; else ...原创 2018-06-09 19:24:37 · 934 阅读 · 2 评论 -
杭电OJ2025 2026 2027 2028最小公约数 2029
2025一开始思路比较复杂,还想着把“(max)”插入字符串,然后就“烫烫烫”了,后面看了大佬们的答案,原来还有这么简单的方法,可恨我咋就没想到#include <iostream> #include <string> using namespace std;int main(){ string s; while (cin >> s) ...原创 2018-06-16 18:31:19 · 631 阅读 · 0 评论 -
杭电2042 2044 2019 2020-2022
2042.#include<iostream>#include<string>using namespace std; int digui(int x){ if (x == 0) return 3; else return (digui(x-1)-1)*2;}int main(){ int n,m; while (ci...原创 2018-06-14 00:15:56 · 313 阅读 · 0 评论 -
杭电 2033 人见人爱A+B
#include <iostream> #include <string> #include<math.h>using namespace std;int main(){ int n; int AH, AM, AS, BH, BM, BS; int sh, sm, ss; while (cin >> n) { ...原创 2018-06-18 23:22:00 · 219 阅读 · 0 评论 -
杭电oj2034 A-B
#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){ int n, m,t=0; int a[100], b[100]; int c[100]; bool flag; ...转载 2018-06-19 00:00:19 · 304 阅读 · 0 评论 -
杭电oj2046 骨牌铺方格 递归
//注意越到后面数值越大,要用long long定义数组,否则会超阈值#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){ int n; long long a[51]; a[...原创 2018-06-30 21:55:52 · 529 阅读 · 0 评论 -
杭电oj2036 任意多边形面积
#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){ int n; int x[100],y[100]; double are; while (cin >> ...原创 2018-06-20 15:50:17 · 495 阅读 · 2 评论 -
杭电oj2035 A^B
#include<iostream>#include<string.h>#include<math.h>using namespace std;int main(){ int a, b; while (cin>>a >> b) { if (a == 0 && b == 0...原创 2018-06-20 15:15:13 · 225 阅读 · 0 评论 -
杭电OJ2043 密码
#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){ int n; char a[50]; string str; bool flag[4];...原创 2018-06-26 23:11:40 · 425 阅读 · 0 评论 -
杭电oj2040 亲和数
需注意AB的范围,最大是600000,所以需要用长整型表示#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){ int n; long suma,sumb; long a, b...原创 2018-06-26 22:41:16 · 380 阅读 · 0 评论 -
杭电2050 折线分割平面
思路请戳https://blog.youkuaiyun.com/lishuhuakai/article/details/8518245#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){...原创 2018-07-01 00:34:00 · 208 阅读 · 0 评论 -
杭电oj2049 错排*排列组合
#include <iostream> #include <string>#include<math.h>#include<algorithm>using namespace std;long long jiecheng(int x){ long long s = 1; for (int i = 1; i <= x...原创 2018-07-01 00:02:48 · 529 阅读 · 0 评论 -
杭电2048 错排 递推
错排递推公式f(n)=(f(n-1)+f(n-2))*(n-1) #include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){ int n; int l; ...原创 2018-06-30 23:15:31 · 246 阅读 · 0 评论 -
杭电oj 2047 eof串 递归
#include <iostream> #include <string> #include<math.h>#include<algorithm>using namespace std;int main(){ int n; long long a[51]; a[1] = 3; a[2] = 8; for (int i ...原创 2018-06-30 22:09:16 · 351 阅读 · 0 评论 -
杭电OJ2015-2018 2041
2015.把前天做过的题再做一遍,发现报了错,然后注意到了细节:)#include<iostream>using namespace std;int main(){ int n, m; int count = 0, sum = 0; int i,j=0; int a[100],b[100]; while (cin >> n &...原创 2018-06-13 00:08:04 · 490 阅读 · 0 评论