#include <stdio.h>#include <string.h>int max( int a, int b ){return a > b ? a : b;}int d[1001][1001];char s1[2000];char s2[2000];int main(){int la, lb, N;scanf( "%d", &N );while( N-- ){memset( d, 0, sizeof(d) );scanf( "%s", s1 );
S-Trees A Strange Tree (S-tree) over the variable set is a binary tree representing a Boolean function. Each path of the S-tree begins at theroot node and consists of n+1 nodes. Each of the S-tree's nodes has adepth, which is the amount of nodes
題很簡單,思路也不難,就是一個貪心,但是第一次寫用最直觀的類比,結果導致了TLE,必然,資料量大概是100000,我的程式大概最壞的話應該是個O(n2)TLE 了這是我的TLE代碼#include <stdio.h>#include <string.h>#include <stdlib.h>int a[200000];long long cost;int n;inline int abs( int a ){if( a < 0 )return
Train Swapping At an old railway station, you may still encounter one of the last remaining ``train swappers''. A train swapper is an employee of the railroad, whose sole job it is to rearrange the carriages of trains.Once the carriages are
Problem CA mid-summer night’s dreamInput:standard inputOutput:standard output This is year 2200AD. Science has progressed a lot in two hundred years. Two hundred years is mentioned here because this problem is being sent back to 2000AD with the help
Problem F: Factoring Large NumbersOne of the central ideas behind much cryptography is that factoring large numbers is computationally intensive. In this context one might use a 100 digit number that was a product of two 50 digit prime numbers. Even
Problem A: The Monocycle A monocycle is a cycle that runs on one wheel and the one we will be considering is a bit more special. It has a solid wheel colored with five different colors as shown in the figure:The colored segments make equal angles (
A polynomial of degree n can be expressed asIf k is any integer then we can write:Here q(x) is called the quotient polynomial ofp(x) of degree (n-1) and r is any integer which is called the remainder.For example, if p(x) = x3 - 7x2+ 15x - 8 andk = 3
連結:http://acm.hdu.edu.cn/showproblem.php?pid=1394題目大意:給一個n個數的序列a1, a2, ..., an ,這些數的範圍是0~n-1, 可以把前面m個數移動到後面去,形成新序列:a1, a2, ..., an-1, an (where m = 0 - the initial seqence)a2, a3, ..., an, a1 (where m = 1)a3, a4, ..., an, a1, a2 (where m = 2)...an,
連結:http://acm.hdu.edu.cn/showproblem.php?pid=1754分析與總結:線段樹求區間最大值,好像也沒什麼可講的。代碼:#include<iostream>#include<cstdio>#include<cstring>#define lson(x) (x<<1)#define rson(x) (lson(x)|1)using namespace std;typedef int Type;const int