10 2012 档案
摘要:题意:逻辑运算题,最多有5个变量,依次枚举就可以AC了kANCEa && ba || b!a!a || ba ==b思路:之前是用递归写的,但是WA或是超时,郁闷。。。后来在网上参考了别人的代码,用栈一次AC。10962407NY_lv103295Accepted208K16MSC++1648B2012-10-27 20:08:57用栈AC代码#include <iostream>#include <stack>//#include <fstream>#include <string>using namespace std;//o
阅读全文
摘要:题意: 4*4的矩阵, “+”表示关闭, “—”表示开启, 当改变一个位置的时候,其所在的行和列都会取反,求最少需要多少步能将其全部置为“-”。思路:暴力枚举+BFS。 先写一个异或的数组,然后依次异或。 其中用pt 保存路径。10957265NY_lv102965Accepted1240K938MSC++1103B2012-10-26 11:24:33View Code #include <iostream>#include <queue>using namespace std;int chang[] = { 63624, 62532, 61986, 61713, 3
阅读全文
摘要:题意:给定n, p, 求pow(p, 1/n)10955211NY_lv102109Accepted196K0MSC++192B2012-10-25 18:56:50View Code #include <iostream>#include <math.h>using namespace std;int main(){ double n, p; while (scanf("%lf %lf", &n, &p) !=EOF) { printf("%0.0lf\n", pow(p, 1/n)); } return 0;}
阅读全文
摘要:题意: 海上有一些岛屿(数目为n),需要在岸边(x 轴)修建一些雷达站覆盖这些岛屿,雷达的覆盖范围是d , 求最少需要多少雷达。思路:求出每个岛屿能被雷达覆盖的,雷达可以放置的最左边和最右边位置,然后将每个岛屿按照左边的位置排序,放置雷达。10955167NY_lv101328Accepted300K47MSC++1092B2012-10-25 18:45:07View Code #include<iostream>#include<algorithm>#include<vector>#include<math.h>using namespace
阅读全文
摘要:题意: 老鼠有m 磅猫粮, 有n 个房间,每个房间有j[i] 磅javaben, 求老鼠能够最多能换取多少javabean,交换规则是:用 f[i] *a% 换得j[i] * a% 磅javaben.如:j[i] = 7, f[i] = 2, 那么老鼠只要拿2 磅的猫粮就可以换7 磅的javaben, 那1 磅猫粮可以换3.5 磅 javaben,以此类推。思路: 说是简单贪心,每个房间求一个scale = f[i] / j[i], 从最大的scale 换起,思路很明显, 就是一些细节没考虑的啊,WA了无数次,%>_<%。。。WA: 1.是数据类型定义错了。 2.然后是没有考虑到当
阅读全文
摘要:题意:一个4 * 4 的棋盘, 翻转一个点的时候其上下左右都会翻转,求将它们翻转成相同的颜色至少要多少步(全部置为白棋或者是黑棋)。思路:纯 BFS,有一点小技巧,很巧妙的将棋盘的黑白转换成0101,然后用异或取反。10945224NY_lv101753Accepted564K32MSC++988B2012-10-23 09:53:08View Code #include <iostream>#include <queue>using namespace std;int arr[16]={0xc800,0xe400,0x7200,0x3100,0x8c80,0x4e40
阅读全文
摘要:题意: 给定一个数组序列,求连续的一段子序列之和最大,并输出其和以及起始位置和终止位置。思路:第一道DP题目,sum[i] 表示以i 为终点的最大和,起始位置用st[i]保存。69595682012-10-21 10:29:52Accepted100315MS1392K732 BC++罗维View Code #include <iostream>using namespace std;#define N 100002int a[N];int sum[N]; //以sum[i] 为终点的最大值int st[N]; //以位置i向前扩展int main(){ int t, n; ...
阅读全文
摘要:题意:给一个树组,长度为1,2,3。。。n ,求全排序里面第m小的序列。思路:调用库函数next_permutation 水过其中库中另一函数prev_permutation与next_permutation相反,由原排列得到字典序中上一次最近排列。69395642012-10-18 11:10:31Accepted102731MS260K306 BC++罗维View Code 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int main() 6 { 7 int f[10
阅读全文
摘要:题意:质数环,相邻的两个数加起来要是质数,这些数只能从2 - n 里面选择。解题思路:纯 DFS ,需要注意的是最后一个数,和第一个数连在一起了所以还有判断arr[n-1] + arr[0] 是不是质数。分类:DFS69245082012-10-15 19:26:15Accepted1016906MS260K996 BC++罗维View Code 1 #include <iostream> 2 #include <memory.h> 3 using namespace std; 4 5 int n; 6 int arr[30]; 7 bool used[30]; 8 9
阅读全文
摘要:题意: 大致是给一个数 target, 和一个字符串 str, 然后从字符串str 中选择五个字母满足方程v - w^2 + x^3 - y^4 + z^5 = target 即可,但是在此之前需要给字符串排下序(这个地方纠结了好久,在网上看了资料才明白要排序,尼玛)解题思路:字符串最多才12,果断DFS 水过了。分类: DFS ,类似于背包问题。69242932012-10-15 18:57:36Accepted1015109MS256K950 BC++罗维View Code 1 #include <iostream> 2 #include <algorithm> 3
阅读全文
摘要:题意:一个N * M 的迷宫, 起点为S, 终点为D , 障碍为X, 问你是否恰好花费时间T 的时候到达终点D。思路:DFS ,纯粹的搜索会直接超时, 所以需要通过剪枝, 也是在网上看到别人说奇偶剪枝,加进去直接AC了。69234052012-10-15 15:09:01Accepted1010640MS256K1465 BC++罗维View Code 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <math.h> 5 using namespac
阅读全文
摘要:PresentationError 输出格式错误while (scanf("%d" &n) != EOF)
阅读全文
摘要:View Code 1 /* 2 Sum Problem 3 4 Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) 5 Total Submission(s): 171363 Accepted Submission(s): 40796 6 7 8 Problem Description 9 Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).10 11 In this problem, your...
阅读全文
摘要:View Code 1 /* 2 A + B Problem 3 4 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) 5 Total Submission(s): 242043 Accepted Submission(s): 71455 6 7 Problem Description 8 Calculate A + B. 9 10 Input11 Each line will contain two integers A and B. Process to en...
阅读全文

浙公网安备 33010602011771号