#include <iostream>
#include <cmath>
using namespace std;
const double r = acos(0.5) ;
int a1, b1, c1, d1;
int a2, b2, c2, d2;
inline int sq(const int x) {return x * x;}
inline int cu(const int x) {return x*x *x;}
int main ( )
{
cout.flags(ios::fixed) ;
cout.precision(4) ;
cin >> a1 >> b1 >> c1 >> d1;
cin >> a2 >> b2 >> c2 >> d2;
int t= sq (a1-a2) +sq (b1-b2) +sq (c1-c2) ;
if (t <= sq(d2-d1)) cout << cu(min(d1,d2))*r*4;
else if (t >=sq (d2+d1)) cout << 0;
else {
double x=d1-(sq (d1) - sq (d2) +t) / sqrt (t) / 2;
double y=d2-(sq (d2) - sq (d1) +t) / sqrt (t) /2;
cout << (x*x* (3*d1-x) +y*y* (3*d2-y)) *r;
}
cout << endl;
return 0;
}
#include <algorithm>
#include <iostream>
using namespace std;
int n,a[1005] ;
struct Node
{
int h, j, m, w;
Node (const int _h, const int _j, const int _m, const int _w) :
h (_h) , j (_j) , m (_m) ,w (_w)
{}
Node operator+ (const Node &o) const
{
return Node(
max(h,w+o.h) ,
max(max (j,o.j) ,m +o.h) ,
max(m+o.w,o.m) ,
w+o.w) ;
}
} ;
Node solve1 (int h,int m)
{
if (h>m)
return Node (-1, -1, -1, -1) ;
if (h==m)
return Node(max(a[h], 0) , max(a[h], 0) , max(a[h], 0) ,a[h]) ;
int j= (h + m) >> 1;
return solve1 (h, j) + solve1(j+1, m);
}
int solve2 (int h, int m)
{
if (h>m)
return -1;
if (h==m)
return max(a[h], 0) ;
int j= (h+m) >> 1;
int wh=0,wm =0;
int wht=0,wmt=0;
for (int i = j; i >= h; i--) {
wht +=a[i] ;
wh =max(wh,wht) ;
}
for (int i = j+1; i <= m; i++){
wmt +=a[i] ;
wm=max(wm,wmt) ;
}
return max (max(solve2(h, j), solve2(j+1,m)) ,wh + wm) ;
}
int main ( )
{
cin >> n;
for (int i=1; i <= n; i++) cin >> a[i];
cout << solve1(1, n).j << endl;
cout << solve2(1, n) << endl;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
char base [64] ;
char table [256] ;
void init ()
{
for (int i=0; i < 26; i++) base[i] = 'A' + i;
for (int i=0; i < 26; i++) base[26 + i] = 'a' + i;
for (int i=0; i < 10; i++) base[52 + i] = '0' + i;
base [62] = '+', base[63] = '/';
for (int i = 0; i < 256; i++) table[i] = 0xff;
for (int i = 0; i < 64; i++) table[base[i]]= i;
table ['='] =0;
}
string encode (string str)
{
string ret;
int i;
for (i=0; i + 3 <= str.size(); i+=3){
ret +=base [str [i] >> 2] ;
ret +=base [ (str [i] &0x03) <<4|str[i+1]>> 4];
ret +=base [ (str [i +1] &0x0f) <<2|str[i+2]>> 6];
ret += base [str [i+2] & 0x3f] ;
}
if (i < str.size()){
ret +=base [str [i] >> 2];
if (i+1==str.size () ) {
ret +=base [ (str [i] &0x03) <<4];
ret +="==";
}
else{
ret += base [ (str [i] & 0x03) <<4|str[i+1] >> 4];
ret += base [ (str [i +1] & 0x0f) << 2];
ret +="=";
}
}
return ret;
}
string decode (string str)
{
string ret;
int i;
for (i=0; i < str.size(); i +=4){
ret +=table [str [i] ] <<2|table[str[i+1]]>>4;
if (str[i + 2] != '=')
ret += (table[str[i+1]]& 0x0f) << 4|table[str[i+2]] >> 2;
if (str[i+3] != '=')
ret += table [str [i + 2] ] << 6|table[str[i +3]];
}
return ret;
}
int main ()
{
init () ;
cout << int(table[0])<< endl;
int opt;
string str;
cin >> opt >> str;
cout << (opt ? decode(str) : encode(str))<< endl;
return 0;
}
#include <iostream>
#include <cstdlib>
#include <climits>
using namespace std;
const int M=10000;
bool Vis[M+1] ;
int F[M+1] ;
void update (int &x, int y) {
if (y<x)
x=y;
}
int main () {
int n;
cin >> n;
for (int i = 0; i <=M; i++)
F[i]= INT_MAX;
___(1)___;
int r=0;
while (___(2)___) {
r++;
int x=0;
for (int i = 1; i <= M; i++)
if (___(3)___)
x=i;
Vis[x]=1;
for (int i = 1; i <= M; i++)
if (___(4)___) {
int t=F[i] +F[x] ;
if (i+x <=M)
update (F[i+x] ,t) ;
if (i!=x)
update (F[abs (i-x)] ,t) ;
if (i%x==0)
update (F[i/x] ,t) ;
if (x%i==0)
update (F[x/i] ,t) ;
}
}
cout <<F[n] << endl;
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
const int MAXN=100000, MAXT=MAXN << 1;
const int MAXL = 18, MAXB = 9, MAXC =MAXT/MAXB;
struct node {
int val;
int dep, dfn, end;
node *son[2];//son[0],son[1]分别表示左右儿子
} T[MAXN] ;
int n,t,b,c, Log2 [MAXC+1] ;
int Pos [(1 << (MAXB-1))+5],Dif[MAXC + 1];
node *root, *A[MAXT] , *Min[MAXL][MAXC];
void build( ) { //建立 Cartesian 树
static node *S [MAXN +1] ;
int top=0;
for (int i=0; i<n; i++) {
node *p=&T [i] ;
while (top &&S[top]->val<p->val)
___(1)___;
if (top)
___(2)___;
S [++top] =p;
}
root=S[1] ;
}
void DFS(node *p) { //构建 Euler 序列
A [p-> dfn = t++] =p;
for (int i =0; i < 2; i++)
if (p->son[i]) {
p->son[i]->dep = p->dep +1;
DFS(p->son[i]) ;
A [t++] =p;
}
p->end =t - 1;
}
node *min (node *x,node *y) {
return ___(3)___?x:y;
}
void ST_init() {
b= (int) (ceil(log2(t)/2));
c=t/b;
Log2 [1] =0;
for (int i =2; i <=c; i++)
Log2 [i] =Log2[i>>1] +1;
for (int i = 0; i < c; i++) {
Min[0][i]=A[i*b];
for (int j=1; j< b; j++)
Min[0][i] = min(Min[0][i],A[i*b+j]);
}
for (int i=1,l=2; l<= c; i++, l<<= 1)
for (int j=0; j+1 <= c; j++)
Min[i][j] = min(Min[i-1][j], Min[i-1][j+(l>>1)]) ;
}
void small_init( ) { //块内预处理
for (int i=0; i <=c; i++)
for (int j = 1; j<b&& i *b+j<t; j++)
if (___(4)___)
Dif [i]|=1 << (j-1);
for (int S =0; S<(1<<(b-1)); S++) {
int mx=0,v=0;
for (int i=1; i<b; i++) {
___(5)___;
if (v <mx) {
mx=v;
Pos [S] =i;
}
}
}
}
node *ST_query (int l, int r) {
int g=Log2 [r-1+1] ;
return min (Min[g][1],Min[g][r-(1<<g)+1]);
}
node *small_query(int l,int r) { //块内查询
int p=1/b;
int S=6;
return A[1+Pos[S]] ;
}
node *query (int l,int r) {
if (l>r)
return query (r, 1) ;
int pl=l/b,pr =r/b;
if (pl ==pr) {
return small_query (l,r) ;
} else {
node *s = min(small_query (l, pl*b+b-1),small_query (pr*b,r) ) ;
if (pl+1<=pr-1)
s = min (s, ST_query(pl+1,pr-1));
return s;
}
}
int main () {
int m;
cin >>n>>m;
for (int i=0; i<n; i++)
cin >> T[i].val;
build () ;
DFS (root) ;
ST_init () ;
small_init () ;
while (m--) {
int l,r;
cin >>l>>r;
cout << query(T[1].dfn, T[r].dfn)->val << endl;
}
return 0;
}