
ACM
「已注销」
前后左右端工程师
展开
-
排队买票_HDU
2017年1月22日,22:12:49 解题思路:排列组合加错排#include "stdio.h"int main(void){ int m,n,k; while(~scanf("%d%d%d",&m,&n,&k)) { if(n<k) printf("0\n"); //2元小朋友比1元小朋友多原创 2017-03-04 19:30:32 · 838 阅读 · 0 评论 -
01串_NYOJ
#include <stdio.h> #define maxn 10001int s[maxn];int main(){ s[1]=2; 当n==1时(2个):0,1 s[2]=4; 当n==2时(4个):00,11,10,11 s[3]=7; 当n==3时(7个):000,111,110,011,010,001,100 s[4]=12; 当n==4时原创 2017-03-05 15:54:47 · 580 阅读 · 0 评论 -
统计字符_HDU
2017年2月12日,15:46:45输入两个字符串,判断第二个字符串中 有多少 属于第一个字符串的字符,输出字符以及对应次数。这个应该叫做哈希表的映射吧。。把第二个字符串所有的字符全部映射在 整型数组,然后再遍历第一个字符串,进行对应输出。 代码如下:#include <stdio.h>int main(){ char s[100]; char a[15];原创 2017-03-05 15:58:35 · 325 阅读 · 0 评论 -
十进制转换任意进制_CJ
#include<stdio.h>int main(void){ int i,n,r,x; char prt[1000],num[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; while(~scanf("%d%d",&n,&r)) { if(n<0)x=转载 2017-03-06 23:20:52 · 458 阅读 · 0 评论 -
开灯问题_POJ
#include <stdio.h>#include <string.h>#define maxn 1010int a[maxn];int main(){ int n,k,first=1; memset(a,0,sizeof(a)); scanf("%d%d",&n,&k); for(int i=1;i<=k;i++) for(int j=原创 2017-03-05 15:51:43 · 621 阅读 · 0 评论 -
Andryusha and Socks_Codeforces
题意:给你 n双袜子,袜子全在柜子里,每次只能拿一只袜子放在桌子上,如果有一对袜子出现,则这对袜子消失 现在给你取出袜子的序号,求桌子上最多的时候有多少只袜子 思路:定义一个数组,映射袜子序列的数量,在定义一个变量 z,永远指向桌子上的袜子数量 在定义一个变量 num,指向出 z变化中的最大值,输入结束 num 既是答案 #include<原创 2017-03-06 22:49:25 · 439 阅读 · 0 评论 -
Oil Deposits_HDU
题意:给你图案,判断有多少个 @ ,如果 @与@相邻对角垂直,则会被算成一个。 思路:遍历 图案,找到 @,对其四周进行递归,并每一次执行,都把其原来图案换点。 结束条件,如果四周都没有@ 即可退出 深搜水题,做法也比较随意。 代码如下:#include<bits/stdc++.h>using namespace std;const int maxn=120;char Val[原创 2017-03-06 23:15:08 · 325 阅读 · 0 评论 -
抢红包_GPLT
#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;struct MJ{ int No; double Ac; int Co;}Mj[10010];bool cmp(MJ x,MJ y){ if(x.Ac>y.Ac) return true原创 2017-03-07 10:37:49 · 487 阅读 · 0 评论 -
哥德巴赫猜想_CJ
#include <stdio.h>#include <algorithm>#define N 2016using namespace std;struct Mj{ int a; int b;}stu[N];bool cmp(Mj x,Mj y){ if(x.b!=y.b) return x.b<y.b; else return原创 2017-03-07 10:35:10 · 512 阅读 · 0 评论 -
ACM前奏模板
/*插入排序输入排序:4 9 1 6 7 2 3 84 91 4 91 4 6 91 4 6 7 91 2 4 6 7 91 2 3 4 6 7 91 2 3 4 6 7 8 9 */#include <stdio.h> int num[1000];int main(){ int n,x,y; printf("输入排序的总个数:"); scanf("原创 2017-03-06 12:03:32 · 599 阅读 · 0 评论 -
大数运算_HDU
2016年12月29日,21:08:39#include<stdio.h>#include<string.h>int main(){ char a[1000],b[1000],c[1001]; int i,j=1,p=0,n,n1,n2; scanf("%d",&n); while(n--) { scanf("%s %s",转载 2017-03-05 16:02:50 · 506 阅读 · 0 评论 -
Bone Collector_HDU
2017年3月5日15:59:34裸Dp#include<bits/stdc++.h>using namespace std;const int maxn=1010;int Value[maxn];int Space[maxn];int Dp[maxn];int main(){ int T,n,m; cin>>T; while(T--){ cin>原创 2017-03-05 16:00:20 · 346 阅读 · 0 评论 -
Pupils Redistribution_Codeforces
2017年3月4日18:54:05 思路:两个数组存出现次数,相加为奇数,必失败,最后还要除2#include<bits/stdc++.h>using namespace std;int a[120],c[120];map<int,int>A,C;int main(){ int n; cin>>n; for(int i=1;i<=n;++i){原创 2017-03-04 19:15:23 · 427 阅读 · 0 评论 -
Shell Game_Codeforces
sj:2017年2月28日22:15:41 此题利用枚举,遍历三个初始化位置 另外,此题还有规律,6个一循环,所以 移动的总数:n%6 如果经过移动后得的结果 等于输入的位置,而返回后直接结束,否则 继续遍历 两个关键点:1.枚举三个位置 2.6个一循环(在此谢谢康瑞大神的指导) 代码如下:#include <stdio.h>long long n,pos;bool M原创 2017-03-04 19:17:38 · 438 阅读 · 0 评论 -
Next Round_Codeforces
2017年3月1日14:45:47 完全题意理解的锅 WA了两发 给出的K 是所求 数组中的元素有多少是大于 下标值为 K-1 的元素 的问题 而自己 却理解成数组中的元素有多少是大于 K的问题 。。。 坑点:如果循环到的数组元素为0 则直接跳出 不进行计数 代码如下: #include <iostream>#include <cstdio>using namespace std原创 2017-03-04 18:52:16 · 305 阅读 · 0 评论 -
Mahmoud and a Triangle_Codeforces
2017年2月28日22:17:33 简单题:给你一组数,找出三个 是否能组成三角形 解题思路:先对数组进行排序,定义三个变量,一个为最短的长度,一个为中等长度,一个为最长的长度 然后进行判断:两边之和小于第三边,两边之差大于第三边 符合就直接输出YES return 循环后,如果没结素,就在外面输出NO 代码如下:#include <stdio.h>#include <algor原创 2017-03-04 18:50:26 · 422 阅读 · 0 评论 -
k-th divisor_Codeforces
Ok,声明下2017年2月10日23:27:51 这两天因为她和朋友,一直没有做题,也可能自己太懒散 这题让我记住的关键就是:转换说明符:%lld 丢了!然后便一错再错,错一次还要修一次电脑,开心的不得了 嗯,这款华硕笔记本,一直出网络故障(以至于打开网页一度失败),并且自己状态不佳,像个无头苍蝇 所以不得不苦笑承认,自己真是个Loser。 Ok,说下解题步骤 : 特别声原创 2017-03-04 18:49:02 · 553 阅读 · 0 评论 -
Gotta Catch Em' All!_Codeforces
2017年2月5日23:20:31 这题 WA了两发,是因为, for循环中的判断条件成了,i<strlen(s) ,这样 每次循环都会 调用len函数 所以 应该先定义 一个变量等于strlen(s) 然后用常量作为循环条件 要谨记这个教训!代码如下: #include <stdio.h>#include <string.h>#define maxn 100001char s[max原创 2017-03-04 18:47:02 · 499 阅读 · 0 评论 -
Blown Garland_Codeforces
虽然一次AC,但还是忍不住说,大水题! 题意:给4个字母,4个为一周期,判断在对应的字母中 存在多少个感叹号。 没什么好说的,我服这水题,提交的时候不小心,在每个输出的结果后面都加了个换行符,也是AC了。。 还花费时间来思考 字符串长度为 4的情况。。。代码如下:#include <stdio.h>char s[103];struct MJ{ int num; cha原创 2017-03-04 18:43:42 · 276 阅读 · 0 评论 -
String Task_Codeforces
2017年3月1日15:16:15 长见识,Y,W 原来是半元音字母代码如下:#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){ char A[110]; scanf("%s",A); int len=strlen(A);原创 2017-03-04 19:19:24 · 344 阅读 · 0 评论 -
Theatre Square_Codeforces
2017年3月1日14:00:42 题意:给三个数,前两个为组成长方形的长和宽,后一个为正方形的边长,求需要几个正方形能覆盖住长方形 解题思路: 先找到长方形的最大边长max,最小边长min,如果正方形的边长 大于max,直接输出1 return 0; 如果正方形的边长大于min,如果 max%a==0 输出max/a 否则输出 max/a+1 注意,上面这两个条件 一定要先行原创 2017-03-04 19:20:58 · 456 阅读 · 0 评论 -
USB vs PS2_Codeforces
2017年2月12日,14:29:38 一道麻烦的水题 代码如下:#include <stdio.h>#include <algorithm>using namespace std;#define maxn 1500001long long U[maxn]={0};long long P[maxn]={0};long long R[maxn]={0};int原创 2017-03-04 19:23:05 · 442 阅读 · 0 评论 -
数塔_HDU
#include <stdio.h>#define max(a,b) a>b?a:b;int main(){ int n; scanf("%d",&n); int High; int i,j; int Ta[500][500]={0}; while(n--) { scanf("%d",&High); for原创 2017-03-05 15:52:53 · 557 阅读 · 0 评论 -
熄灯问题_POJ
郭炜教授#include <stdio.h>#include <string.h>int GetBit(char c, int i) { return (c >> i) & 1;}void SetBit(char *c, int i, int v) { if (v) *c |= (1 << i); else *c &= ~(1 << i);转载 2017-03-05 15:48:46 · 460 阅读 · 0 评论 -
完美立方_POJ
#include <stdio.h>int main(){ int n,a,b,c,d; scanf("%d",&n); for(a=2;a<=n;++a) for(b=2;b<a;++b) for(c=b;c<a;++c) for(d=c;d<a;++d) if原创 2017-03-05 15:46:36 · 1076 阅读 · 0 评论 -
生理周期_POJ
2017年2月16日,10:49:20 郭炜教授代码 解题思路:先找到一个体力高分的日子(第一个for循环)(当然,其他高分也可以) 然后再找到一个情商高分的日子,在此期间有很多天 是可以避开的,因为要保证,结果是三个数的最大公倍数 所以 第二个for循环,每次间隔 一个体力高分的周期 去做尝试 ,这样就能确保,结果一定是体力高分倍数 直到找到一个即是 体原创 2017-03-05 15:45:26 · 729 阅读 · 0 评论 -
称硬币_POJ
2017年2月16日,18:01:17解题思路--郭炜,自己脑子笨,没有实力解决,郭炜教授代码 也是琢磨半天 才明白。失落,佩服。 对于 每一枚硬币 先假设 它是轻的,看这样 是否符合称量结果。如果符合,问题解决。如果不符合,就假设 它是重的,看是否符合称量结果。把所有硬币都试一遍,一定能找到特殊硬币。 代码如下:#include <stdio.h>#include <stri原创 2017-03-05 15:43:22 · 591 阅读 · 0 评论 -
最长上升子序列
2017年2月23日,12:25:03——初始Dp 大致算法: 1.开始额外建立一个用来保存长度的数组 2.两层循环,第一层循环 遍历 除第一个元素之外的所有元素, 以每个元素 为终点的想法。来找到:从第一个元素 到该元素的上升的长度 用数组保存,再找出最大值 注意 状态转移方程: len[i]=max(len[i],len[j]+1);原创 2017-03-05 15:40:41 · 253 阅读 · 0 评论 -
饭卡_HDU
2017年2月23日,23:17:18——初识Dp先利用贪心,先把 钱-=5,这5元用来买最贵重的东西,int Max = val[n-1]; 然后循环遍历到 倒数第二个元素 ,因为最贵的东西 已经买走,然后对 钱-=5 的剩下钱 进行操作 如果剩下的钱 连最便宜的东西 都买不成,就不进行操作 if(money>=val[0])两层循环,第一层 遍历 n-1个价位,第二层 遍历 在原创 2017-03-05 15:37:11 · 532 阅读 · 0 评论 -
Way Too Long Words_Codeforces
2017年3月1日14:28:48 不得不说,大水题 给你字符串,如果长度大于10,输出第一个字符 与 字符长度减 2 与 最后一个字符 否则 直接输出字符 还有,做水题 真过瘾 代码如下:#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){ int原创 2017-03-04 19:26:59 · 451 阅读 · 0 评论 -
Watermelon_Codeforces
2017年3月1日14:19:36 (这题做的很傻逼) 给你个数,判断是否可以 分成两个偶数 解题思路:如果给的数 是奇数直接输出NO 坑点:特么的 给的是 2 ,就会变成 一个 2 与 一个 0,完全大意(不细心) 所以说 做题一定要细心,一定要考虑临界值,敏感值 代码如下:#include <iostream> #include <cstdio>using namespace st原创 2017-03-04 19:25:40 · 361 阅读 · 0 评论 -
ACM 算法分类 与 具体题型
ACM 算法分类 与 具体题型一.基本算法:低级:(1)枚举. (poj1753,poj2965)(2)贪心(poj1328,poj2109,poj2586)(3)递归和分治法.(4)递推.(5)构造法.(poj3295)(6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)中级:(1)C++的标准模版库的应用. (poj3096,poj300转载 2017-02-19 22:01:40 · 761 阅读 · 0 评论