摘要: 题目:http://ac.jobdu.com/problem.php?pid=1553/* 分别算出时针和分针的度数,做差之后分几种情况讨论,(-360,-180),[-180,0),[0,180],(180,360). */#include int main(){ int h,m; while (~scanf("%d:%d",&h,&m)) { double hd,md,mdd; hd = (h%12)*30; md = m*6; mdd = ((double)m)/2; double temp = hd ... 阅读全文
posted @ 2014-03-18 11:38 Roly Yu 阅读(243) 评论(0) 推荐(0) 编辑
摘要: /* 可以在筛选质数的同时,算出每组数据中能被各个质数整除的个数, 然后算出[0,s]的个数 [l,r] 的个数即为[0,r]的个数减去[0,l]个数。 */#include #include #include #define maxn 10000010using namespace std;int prime[maxn];int isprime[maxn];int x[maxn];void make_prime(){ memset(isprime, 0, sizeof(isprime)); for(int i = 2;i maxn) l... 阅读全文
posted @ 2014-03-14 22:31 Roly Yu 阅读(356) 评论(0) 推荐(0) 编辑
摘要: /* 贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0. */ 1 #include 2 #define maxn 105 3 int num[maxn]; 4 int main() 5 { 6 int n,c; 7 while(~scanf("%d%d",&n,&c)) 8 { 9 int ans = 0;10 for(int i = 0;i ans)15 ans = temp;16 }17 ans -= c;18 if(ans>=0... 阅读全文
posted @ 2014-03-12 16:25 Roly Yu 阅读(299) 评论(0) 推荐(0) 编辑
摘要: /* 题意就是要找到包含“bear”的子串,计算出个数,需要注意的地方就是不要计算重复。 */ 1 #include 2 #include 3 #include 4 #define maxn 5005 5 6 char str[maxn]; 7 int pos[maxn]; 8 int main() 9 {10 while(~scanf("%s",str))11 {12 int p = 1;13 memset(pos, 0, sizeof(int));14 int len = (int)strlen(str);15 ... 阅读全文
posted @ 2014-03-12 14:27 Roly Yu 阅读(232) 评论(0) 推荐(0) 编辑
摘要: /* 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2955 题意:Roy想要抢劫银行,每家银行多有一定的金额和被抓到的概率,知道Roy被抓的最 大概率P,求Roy在被抓的情况下,抢劫最多。 分析:考虑其反面。被抓概率可以转换成安全概率,Roy的安全概率大于1-P时都是安全的。抢劫的金 额为0时,肯定是安全的,所以d[0]=1;其他金额初始为最危险的所以概率全为0; 注意:不要误以为精度只有两位。*/#include<stdio.h>#include<iostream>#include<stdlib.h>#inc. 阅读全文
posted @ 2013-06-02 14:28 Roly Yu 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4522建两个图,分别用dijstra。#include<stdio.h>#include<iostream>#include<string.h>#include<math.h>#include<string>#include<algorithm>#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;const int 阅读全文
posted @ 2013-05-28 15:56 Roly Yu 阅读(143) 评论(0) 推荐(0) 编辑
摘要: /* http://codeforces.com/problemset/problem/149/E KMP结合动态规划的思想,正向匹配一边,l[]数组保存的是对于匹配串的每一个位置在模式串能匹配的最左边,也就是首次匹配的位置 逆序再匹配一次,逆向信息保存r[]数组。 再枚举l[i]+r[len-i]*/#include<stdio.h>#include<iostream>#include<string.h>#include<math.h>#include<algorithm>#pragma comment(linker, " 阅读全文
posted @ 2013-05-21 21:30 Roly Yu 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <stdio.h>#include <string>#include <string.h>#include <algorithm>#include <math.h>#include <vector>#include <map>#include <queue>#include <stack>#include <stdlib.h>using namespace std;const int maxn = 10000 阅读全文
posted @ 2013-05-17 11:52 Roly Yu 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 这道题是对SG函数的考查#include <iostream>#include <stdio.h>#include <string>#include <string.h>#include <algorithm>#include <math.h>#include <vector>#include <map>#include <queue>#include <stack>#include <stdlib.h>using namespace std;const int 阅读全文
posted @ 2013-05-17 10:42 Roly Yu 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.fzu.edu.cn/problem.php?pid=1534巴什博奕和尼姆博弈的综合。这里分为最后拿胜利,最后拿失败,分别是nim 和 anti-nim。SG(n) = n%3#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>using namespace std;const int maxn = 10005;int p[maxn];int main(){ int n; while(~scanf("%d&q 阅读全文
posted @ 2013-05-16 14:27 Roly Yu 阅读(170) 评论(0) 推荐(0) 编辑