TopCoder[SRM587 DIV 1]:TriangleXor(550)】的更多相关文章

Problem Statement      You are given an int W. There is a rectangle in the XY-plane with corners at (0, 0), (0, 1), (W, 0), and (W, 1). Let T[x] be the triangle with vertices at (0, 1), (W, 1) and (x, 0). (All points that lie inside the triangle are…
Problem Statement      There is a H times W rectangle divided into unit cells. The rows of cells are numbered 0 to H-1 from top to bottom, and the columns are numbered 0 to W-1 from left to right. The corners of cells are called lattice points. By de…
Problem Statement      Manao is playing a new game called Reflections. The goal of the game is transferring an artifact in 3-dimensional space from point (0, 0, 0) to point (X, Y, Z). There are two types of moves in the game: 1) The player can move t…
#include <set> #include <iostream> #include <string> #include <vector> using namespace std; class Egalitarianism { public: void DFS(vector<string> &v,int p,char flag[]) { int i,j; ;i<v.size();i++) { if (v[p][i]=='Y') {…
#include <string> #include <iostream> using namespace std; class SwappingDigits { public: bool notBiggest(string &s,int pos) { int len=s.length(); ; ;i<len;i++) { )) { return true; } } return false; } int findSmallest(string&s,int p…
A:应该是道语文题,注意边界就好: B:开始考虑的太复杂,没能够完全提取题目的思维. 但还是A了!我愚蠢的做法:二分答案加暴力枚举, 枚举的时候是完全模拟的,比如每次取得时候都是从大到小的去取,最后统计答案! 好吧!忽略这种SB做法,只是提供一种当你想不到的时候,一种暴力破解的思路! 看到的一种正解:我们每次可以取(N-1)个,而且不用加入答案中, 先上代码: for (int i=0;i<s.size();i++) sum+=s[i]; return max(0,sum-N*(m-1));很简…
A,B:很水,注意边界,话说HACK都是这些原因. C: R[I][J]:表示反转I-J能改变冒泡排序的次数: DP方程:dp[i][k]=max(dp[j][k],dp[j][k-1]+dp[j][i])  (0<=j<i) 最后枚举,具体看代码 #include<stdio.h> #include<iostream> #include<vector> #include<algorithm> #include<cmath> #inc…
1. KingdomAndTrees 给出n个数a[1..n],求一个数组b[1..n]满足b严格递增,且b[1]>=1. 定义代价为W = max{abs(a[i]-b[i])},求代价最小值. n<=50 [题解] 二分代价W,贪心判断.当前肯定越小越优,如果下一个加上当前二分的值,小于等于当前这个,那么就肯定不行,依次判即可. // BEGIN CUT HERE // END CUT HERE #line 5 "KingdomAndTrees.cpp" # inclu…
Problem Statement      You might have played the game called Memoria. In this game, there is a board consisting of N rows containing M cells each. Each of the cells has a symbol on its back. Each symbol occurs on exactly two cells on the board. A mov…
现在觉得有空时可以刷一下topcoder的DIV 2的Lvl 3的题目.感觉和刷LeetCode和WikiOi都是不一样的. http://community.topcoder.com/stat?c=problem_statement&pm=11552&rd=14544 http://apps.topcoder.com/wiki/display/tc/SRM+519 这道题目是找规律,从6变到8的过程中有最大的15:而由35到38的过程中最大是39,主要是去掉32后,3->6的过程中…