http://www.ifrog.cc/acm/problem/1028 题解处:http://www.ifrog.cc/acm/solution/4 #include <cstdio> #include <cstring> #include <queue> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; ; ; const doub…
题目链接: Bob and Alice are playing numbers DESCRIPTION Bob and his girl friend are playing game together.This game is like this: There are nn numbers. If op = 11,Bob wants to find two numbers aiai and ajaj,that aiai & ajaj will become maximum value. If…
1152 - Expected value of the expression Time Limit:2s Memory Limit:128MByte Submissions:128Solved:63 DESCRIPTION You are given an expression: A0O1A1O2A2⋯OnAnA0O1A1O2A2⋯OnAn, where Ai(0≤i≤n)Ai(0≤i≤n) represents number, Oi(1≤i≤n)Oi(1≤i≤n) represents op…
分析:a^b+2(a&b)=a+b  so->a^(-b)+2(a&(-b))=a-b 然后树状数组分类讨论即可 链接:http://www.ifrog.cc/acm/problem/1023 吐槽:这个题本来是mod(2^40),明显要用快速乘啊,但是用了以后狂T,不用反而过了,不懂出题人 #include <iostream> #include <algorithm> #include <cmath> #include <vector&g…
题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 然后插入字典树 记录每一个单词的数量 输入一个句子 每一个单词也排序之后查找 依据乘法原理 答案就是每一个单词的数量之积 #include <iostream> #include <cstring> #include <cstdio> #include <algori…
http://www.ifrog.cc/acm/problem/1028 很有趣的一道题,求从n个数里挑出不同的两个,使得他俩'|','&','^'后的值尽量大,求这个最大的结果. 求最大的异或值想到了trie树的一个经典操作,对于按位与,要两个位置都是1才会出现1,我们肯定要贪心操作,优先使高位为1, 这也可以在trie上完成,如果这个位置1的个数>=2,至少有两个以这个前缀开头的数字,我们就认为这个位置可以为1,再往下走考虑下一位, 如果1的个数不满足得话,说明这一位肯定是0了,此时要进…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1028 题目大意:n除了1有多少个因子(包括他本身) 解题思路:对于n的每个因子, 可以用n的所有素因子排列组合而来, n = (a1x1) * (a2 x2) * (a3x3)...*(anxn), 其中ai为n的素因子,那么n的因子的个数等同于(x1 + 1) * (x2 + 1) * (x3 + 1) ... * (xn + 1)中排列, 因为其中一种排列肯定为所有素因子…
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3140 解决:1338 题目描述:     省政府"畅通工程"的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可).现得到城镇道路统计表,表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态.现请你编写程序,计算出全省畅通需要的最低成本. 输入:     测试输入包含若干测试用例.每个测试用例的第1行给出村庄数目N ( 1< N < 100 ):随后的…
题目链接:http://www.ifrog.cc/acm/problem/1031 题意:6个水果中挑出n个,使得其中2个水果个数必须是偶数,问有多少种选择方法. 设中0代表偶数,1代表奇数.分别代表两种水果的奇偶情况,有如下递推式: 初始化的矩阵为: ) 以后写题解就用latex编辑公式了QAQ #include <bits/stdc++.h> using namespace std; typedef long long LL; ; ; LL n; typedef struct Matrix…
1014 - Absolute Defeat Time Limit:2s Memory Limit:64MByte Submissions:257Solved:73 DESCRIPTION Eric has an array of integers a1,a2,...,ana1,a2,...,an. Every time, he can choose a contiguous subsequence of length kk and increase every integer in the c…
特定字符序列的判断 #include <iostream> #include <cstdlib> #include <stack> #include <string> using namespace std; int main() { stack<char> s; stack<char> s1; char c, c1; string str; cin>>str; ; ) { c = str[i]; if (c == '#'…
蛤蛤,略蠢. priority_queue 自定义优先级 和排序是反的 struct node { int x,y; friend bool operator< (node a,node b) { if(a.y<b.y) return 1; if(a.y==b.y&&a.x>b.x) return 1; return 0; } }; priority_queue<node>qu; 思路: +v就加一下,标记一下 对了-v 遍历一下,标记一下 加个优先队列维护一…
1010 - Alarm Time Limit:1s Memory Limit:128MByte DESCRIPTION Given a number sequence [3,7,22,45,116,...] . Please tell me the k -th number. INPUT A number T (T<100) indicates the number of the input cases. Then for each case there only is one integer…
1050 - array Time Limit:3s Memory Limit:64MByte Submissions:494Solved:155 DESCRIPTION 2 array is an array, which looks like: 1,2,4,8,16,32,64......a1=1 ,a[i+1]/a[i]=2; Give you a number array, and your mission is to get the number of subsequences ,wh…
1052 - See car Time Limit:2s Memory Limit:64MByte Submissions:594Solved:227 DESCRIPTION You are the god of cars, standing at (a, b) point.There are some cars at point (xi,yi), . If lots of cars and you are in one line, you can only see the car that i…
SAMPLE INPUT 3 2 2 2 1 1 5 1 4 1 2 3 4 5 4 10 3 1 2 3 4 SAMPLE OUTPUT 1 0 15 前缀和,每个元素都判断一下. #include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <cmath> #include <map> #include <set>…
以下引用部分全都来自:http://blog.csdn.net/ice_crazy/article/details/7478802  Ice—Crazy的专栏 分析: HDU 1028 摘: 本题的意思是:整数划分问题是将一个正整数n拆成一组数连加并等于n的形式,且这组数中的最大加数不大于n. 如6的整数划分为 6 5 + 1 4 + 2, 4 + 1 + 1 3 + 3, 3 + 2 + 1, 3 + 1 + 1 + 1 2 + 2 + 2, 2 + 2 + 1 + 1, 2 + 1 + 1…
初中数学问这个向量 ( *  , 计算学院 , * , *  ) 任取一个向量来自计算机的概率     4*1*100*10000/ 8千万 限定在计科院数字媒体技术专业大二上期选课这个小的范围 学生 ( 陈 ,古 , 周 )43个元素 课程   (openggl , 数字图像 , 高数 , 线代 ) 老师   (瑞狗 , 秀花 , 佳佳  , 彭晓 )  // 假设4个老师都能教上面的课,风格不同 {   {陈 , openggl  , 瑞狗} , {陈 , openggl, 秀花}   {周…
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another comput…
点击传送 Alice’s Stamps Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1448    Accepted Submission(s): 501 Problem Description Alice likes to collect stamps. She is now at the post office buying so…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5115 题目大意:前面有n头狼并列排成一排, 每一头狼都有两个属性--基础攻击力和buff加成, 每一头狼的攻击力等于他自身的基础攻击力加上旁边狼对他的buff加成. 现在你被这群狼围着了, 必须将这些狼全部击败, 你才能逃出, 你每攻击一头狼,收到的伤害是狼的总攻击力.现在问,你逃出这些狼的围攻需要的最小代价(收到的伤害): 解题思路:声明dp数组, dp[i][j]代表从i到j的区间杀死所有狼的最…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1257 跟hdu2196一样,两次dfs //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #inc…
题目链接:http://acm.swust.edu.cn/problem/0648/ Time limit(ms): 1000 Memory limit(kb): 65535   有这样一本字典,它每个单词一页,单词没有相同字母. 就像这样: a 1 b 2 . . z 26 ab 27 . . az 51 ba 52 bc 53 . . Description 多组测试数据,每行是一个串长最大为10由小写字母组成的单词. 以EOF结束. Input 输出这个单词在这本字典的第几页 Output…
Implement a trie with insert, search, and startsWith methods. 实现字典树,前面好像有道题做过类似的东西,代码如下: class TrieNode { public: // Initialize your data structure here. TrieNode():isLeaf(false) { for(auto & t : dic){ t = NULL; } } TrieNode * dic[]; bool isLeaf; };…
迷之好奇 Time Limit: 2000 ms Memory Limit: 65536 KiB Submit Statistic Problem Description FF得到了一个有n个数字的集合.不要问我为什么,有钱,任性. FF很好奇的想知道,对于数字x,集合中有多少个数字可以在x前面添加任意数字得到. 如,x = 123,则在x前面添加数字可以得到4123,5123等. Input 多组输入. 对于每组数据 首先输入n(1<= n <= 100000). 接下来n行.每行一个数字y…
字典树 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Problem Description 遇到单词不认识怎么办? 查字典啊,已知字典中有n个单词,假设单词都是由小写字母组成.现有m个不认识的单词,询问这m个单词是否出现在字典中. Input 含有多组测试用例. 第一行输入n,m (n>=0&&n<=100000&&m>=0&&m<=100000)分别是字典…
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:839 解决:179 题目描述: 给你一个长度为N的,由'('和')'组成的括号序列,你能找出这个序列中最长的合法括号子序列么?合法括号序列的含义便是,在这个序列中,所有的左括号都有唯一的右括号匹配:所有的右括号都有唯一的左括号匹配.例如:((()))()()便是一个长度为10的合法括号序列,而(()))( 则不是. 需要你求解的是,找出最长的合法括号子序列的长度,同时找出具有这样长度的序列个数. 输入: 测试数据包括多个,每个测试数据包…
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:387 解决:224 题目描述: 输入一个字符串,输出该字符串中对称的子字符串的最大长度. 比如输入字符串"google",由于该字符串里最长的对称子字符串是"goog",因此输出4. 输入: 存在多组数据,每组数据一行字符串,长度不大于100. 输出: 输出回文子串的最大长度. 样例输入: google 样例输出: 4 思路: 显而易见的思路是遍历每个数(以及每两个数)作为回文字符串的中心点(点对),然后向…
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4352 解决:1055 题目描述:     现有一笔经费可以报销一定额度的发票.允许报销的发票类型包括买图书(A类).文具(B类).差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元.现请你编写程序,在给出的一堆发票中找出可以报销的.不超过给定额度的最大报销额. 输入:     测试输入包含若干测试用例.每个测试用例的第1行包含两个正数 Q 和 N,其中 Q 是给定的报销额度,N(N<=30)…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15942    Accepted Submission(s): 11245 Problem Description "Well, it seems the first problem is too easy. I will let…