HDU 1153 magic bitstrings(读题+)】的更多相关文章

hdu 1153 magic bitstrings 题目大意 一个质数p,现在让你求一个p-1长度的“01魔法串”.关于这个魔法串是这么定义的:     我们现在把这个串经过一段处理变成一个长宽均为p-1的矩阵,对于第i行的串,是由原来的串按每i位取得的.如果这个矩阵每行的串满足:和原来的串相等或是原来的串按位取反,我们就称这个串是魔法串.(说了一大堆如果还没看懂就去问题底下的Discuss看吧….) 题解 一开始热衷于讨论第一行和最后一行的关系…结果什么也没看出来…后来看了别人的题解,才发现自…
Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera with a few ships, starting a serious of voyages of finding a new route to India. As you know, just in those voyages, Columbus discovered the America…
杭电ACM2076--夹角有多大(题目已修改,注意读题) http://acm.hdu.edu.cn/showproblem.php?pid=2076 思路很简单.直接贴代码.过程分析有点耗时间. // #include <stdio.h> // #include <math.h> // int main() // { // int t; // double h,m,s; // //int h,m,s; // int z; // scanf("%d",&…
选课时间(题目已修改,注意读题) Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2254    Accepted Submission(s): 1791 Problem Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合.你来帮帮他吧.(xhd认为一样学分的课没区别)…
[托业][全真题库]TEST01-03-阅读题…
搞不懂为什么DFS的写法崩了,然后乱暴力,因为题意不是很懂... 主要还是读题吧(很烦 #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int>PII; const double eps=1e-5; const double pi=acos(-1.0); //const int mod=1e9+7;…
写这道题题解的目的就是纪念一下半个小时才读懂题...英文一多读一读就溜号... 读题时还时要静下心来... 题目链接: http://codeforces.com/contest/659/problem/B 题意: 给定地区及来自相应地区的人的分数,每个地区选两个分数最高的人 参加区域赛,如果选出的两个人唯一,则输出名字,否则如果还需要进行下一次比赛,输出"?". 分析: 不唯一的情况就是第二个人和第三个人的分数相同嘛...排个序找一下就好了. 代码: #include <bit…
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 昨晚做了训练赛,然后读题又自闭了QAQ. Average Score ZOJ - 3819 题意: 给你两个班级A.B的人数分别是n.m,告诉你n-1.和m个人的成绩,然后让你确定第n个人的成绩,让n在A班中平均成绩会下降,在B班中,平均成绩会上升. 求第n个人的成绩最小和最大分别是多少. 题解: 数据范围小,直接枚举成绩0~100所有的可能,选出最大最小. Domination ZOJ - 3…
题目 //找规律,123321123321123321…发现这样排列恰好可以错开 // 其中注意题中数据范围: M是行,N是列,3 <= N < 2×M //则猜测:m,m,m-1,m-1,m-2,m-2,……,2,2,1,1求出前m个数字的和就是答案. //发现案例符合(之前的代码第二天发现案例都跑不对,真不知道我当时眼睛怎么了) #include <iostream> #include<stdio.h> #include<string.h> #inclu…
http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 3000 using namespace std; int dp[maxn]; int a,b; int t,n,k; int main() { scanf("%d",&t); while(t--) {…
猜数字 Problem Description A有1数m.B来猜.B每猜一次,A就说"太大"."太小"或"对了" . 问B猜n次能够猜到的最大数.   Input 第1行是整数T,表示有T组数据.以下有T行  每行一个整数n (1 ≤ n ≤ 30)    Output 猜n次能够猜到的最大数   Sample Input 2 1 3   Sample Output 1 7   哎呀妈呀,这题什么意思啊.-----第一感觉 细致理解理解:比方数…
摘自题解: 题意转化一下就是: 给出一列数a[1]...a[n],求长度最长的一段连续的数,使得这些数的和能被M整除. 分析: 设这列数前i项和为s[i], 则一段连续的数的和 a[i]+a[i+1]+...+a[j-1]+a[j]=s[j]-s[i-1], 所以这段连续的数的和能被m整除的条件就是 (s[j]-s[i-1]) % m == 0, 即 s[j]%m-s[i-1]%m == 0, 因此,只需要每一个余数找使s[i]%m等于该余数的最小的i,和s[j]%m等于该余数的最大的j,相减即…
Problem Description 时间过的好快,一个学期就这么的过去了,xhd在傻傻的看着表,出于对数据的渴望,突然他想知道这个表的时针和分针的夹角是多少.现在xhd知道的只有时间,请你帮他算出这个夹角. 注:夹角的范围[0,180],时针和分针的转动是连续而不是离散的. Input 输入数据的第一行是一个数据T,表示有T组数据. 每组数据有三个整数h(0 <= h < 24),m(0 <= m < 60),s(0 <= s < 60)分别表示时.分.秒. Out…
代码: #include<cstdio> #include<cstring> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { int n,k; int a[9],b[9]; scanf("%d%d",&n,&k); for(int i=1; i<=k; i++) { scanf("%d%d",&…
题目: http://acm.hdu.edu.cn/showproblem.php?pid=2222 AC自动机模板题 我现在对AC自动机的理解还一般,就贴一下我参考学习的两篇博客的链接: http://blog.csdn.net/niushuai666/article/details/7002823 http://www.cppblog.com/menjitianya/archive/2014/07/10/207604.html #include<stdio.h> #include<s…
1.HDU 1251 统计难题  Trie树模板题,或者map 2.总结:用C++过了,G++就爆内存.. 题意:查找给定前缀的单词数量. #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #include<cstdio> #define max(a,b) a>b?a:b #define F(i,a,b…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2274 Magic WisKey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 568    Accepted Submission(s): 323 Problem Description On New Year Festival, Liu…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3065 题目大意:多个模式串,范围是大写字母.匹配串的字符范围是(0~127).问匹配串中含有哪几种模式串,且每种模式串出现了多少次. 解题思路: AC自动机模板题.模式串的范围是大写字母,但是匹配串的范围却是(0~127). 如果Trie 开到 128 加上不回收内存,就会MLE. 实际上开到26就行了,find的时候对于c<0||c>26,强制令pos=root出现失配,并开始下一个字符就行了…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2896 题目大意:多个模式串.多个匹配串.其中串的字符范围是(0~127).问匹配串中含有哪几个模式串. 解题思路: AC自动机模板题.注意一下字符范围. cnt记录这个模式串的个数改为这个模式串的index. find的时候,把找到的index压入vector里面即可. 注意有多个匹配串,每次find之后会把last->cnt修改,原因是防止一个模式串出现了多次被压入vector,所以先备份一下,…
http://acm.hdu.edu.cn/showproblem.php?pid=4605 可以离线求解 把所以可能出现的 magic ball  放在一个数组里(去重),从小到大排列 先不考虑特殊情况,对二叉树进行dfs 搜索的过程中需要维护各个magic ball到当前节点的概率 维护:根据当前节点大小 和要去左子树还是右子树的情况,可以得到magic数组中哪个段的x和y需要同时加上多少 可以用线段树维护 特殊情况: 1,根节点一定可以到达 2,到达不了的情况需要标记 代码: #inclu…
Fang Fang Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5455 Description Fang Fang says she wants to be remembered.I promise her. We define the sequence F of strings.F0 = ‘‘f",F1 = ‘‘ff",F2 = ‘‘cff",F…
主题链接: http://acm.hdu.edu.cn/showproblem.php?pid=4016 Magic Bitwise And Operation Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 1315    Accepted Submission(s): 504 Problem Description Given n…
A计划 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15567    Accepted Submission(s): 3886 Problem Description 可 怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验.魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃 公主的肉也能长生不…
Count primes 题目连接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5901 Description Easy question! Calculate how many primes between [1...n]! Input Each line contain one integer n(1 <= n <= 1e11).Process to end of file. Output For each case, output…
Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Cartesian coordinate system,the river is flowing along the x-axis direction. Rower Bo is placed at (0,a) at first.He wants to get to origin (0,0) by boa…
Magic Pen 6 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 582    Accepted Submission(s): 224 Problem Description In HIT, many people have a magic pen. Lilu0355 has a magic pen, darkgt has a ma…
http://acm.hdu.edu.cn/showproblem.php?pid=5066 中学物理题 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <queue> #include <map> #include <iostream> #include &l…
http://acm.hdu.edu.cn/showproblem.php?pid=3183 A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2556    Accepted Submission(s): 999 Problem Description Kiki likes traveling. One day…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1203 I NEED A OFFER! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33303    Accepted Submission(s): 13470 Problem Description Speakless很早就想出国,现在…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1422 解题报告:DP题,要使旅行的城市最多,关键是要选出一个城市作为开始,以这个城市作为开始的城市时,能使拥有的钱能旅行的城市最多,我的做法是把前n-1个城市添加到n个城市的数组后面,这样就不用考虑环的问题了, #include<cstdio> #include<cstring> #include<iostream> using namespace std; ],l[];…