hdu 2018 多校 第五场
Posted mygirlfriends
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 2018 多校 第五场相关的知识,希望对你有一定的参考价值。
1002 小洛洛
开场挂了N发插入排序的我( 最后还是要靠小洛洛写暴力
1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <cmath> 5 #include <cstdlib> 6 #include <algorithm> 7 using namespace std; 8 9 const int N = 12; 10 11 int min_(char s[], int mul, int k, bool fst = false) { 12 if(!*s) 13 return 0; 14 char x = *s; 15 if(k) 16 for(char *p = s; *p; ++p) 17 if(!fst || *p != ‘0‘) 18 x = min(x, *p); 19 int mn = 1000000000; 20 if(*s == x) 21 mn = min_(s + 1, mul / 10, k); 22 else 23 for(char *p = s + 1; *p; ++p) 24 if(*p == x) { 25 swap(*s, *p); 26 mn = min(mn, min_(s + 1, mul / 10, k - 1)); 27 swap(*s, *p); 28 } 29 return (x - ‘0‘) * mul + mn; 30 } 31 int max_(char s[], int mul, int k) { 32 if(!*s) 33 return 0; 34 char x = *s; 35 if(k) 36 for(char *p = s; *p; ++p) 37 x = max(x, *p); 38 int mx = 0; 39 if(*s == x) 40 mx = max_(s + 1, mul / 10, k); 41 else 42 for(char *p = s + 1; *p; ++p) 43 if(*p == x) { 44 swap(*s, *p); 45 mx = max(mx, max_(s + 1, mul / 10, k - 1)); 46 swap(*s, *p); 47 } 48 return (x - ‘0‘) * mul + mx; 49 } 50 51 int main() { 52 int t; 53 scanf("%d", &t); 54 while(t--) { 55 int k; 56 char s[N]; 57 scanf("%s%d", s, &k); 58 int mul = 1; 59 for(char *p = s + 1; *p; ++p) 60 mul *= 10; 61 int mn = min_(s, mul, k, true); 62 int mx = max_(s, mul, k); 63 printf("%d %d ", mn, mx); 64 } 65 return 0; 66 }
1005 BPM136
用圆的面积交模板改一下就好了
1 /* *********************************************** 2 Author :BPM136 3 Created Time :2018/8/6 12:38:56 4 File Name :1005.cpp 5 ************************************************ */ 6 7 #include<iostream> 8 #include<cstdio> 9 #include<algorithm> 10 #include<cstdlib> 11 #include<cmath> 12 #include<cstring> 13 #include<vector> 14 using namespace std; 15 16 const int N = 105; 17 const double pi = acos(-1.0); 18 19 struct point { 20 double x,y; 21 }; 22 23 struct circle { 24 int x,y; 25 int R; 26 }c[N]; 27 int m,R; 28 29 double cirinter(int r1,int x2,int y2,int r2) { 30 double d,s,t,a1,a2,s1,s2,s3; 31 d=sqrt((-x2)*(-x2)+(-y2)*(-y2)); 32 if(d>=r1+r2)return 0; 33 else if(d<r1-r2) return 0; 34 else 35 { 36 a1=acos((r1*r1+d*d-r2*r2)/(2*r1*d)); 37 a2=acos((r2*r2+d*d-r1*r1)/(2*r2*d)); 38 s1=2*a1*r1; 39 s2=2*a2*r2; 40 s=s2-s1; 41 } 42 return s; 43 } 44 45 int main() { 46 int T; 47 scanf("%d",&T); 48 while(T--) { 49 scanf("%d%d",&m,&R); 50 for(int i=1;i<=m;i++) scanf("%d%d%d",&c[i].x,&c[i].y,&c[i].R); 51 double ans=2*pi*R; 52 for(int i=1;i<=m;i++) ans+=cirinter(R,c[i].x,c[i].y,c[i].R); 53 printf("%.10f ",ans); 54 } 55 return 0; 56 }
1007 BPM136
正解st表下压待补
线段树据说势能分析一下是对的?
线段树版本
1 /* *********************************************** 2 Author :BPM136 3 Created Time :2018/8/6 17:45:43 4 File Name :1007G.cpp 5 ************************************************ */ 6 7 #include<iostream> 8 #include<cstdio> 9 #include<algorithm> 10 #include<cstdlib> 11 #include<cmath> 12 #include<cstring> 13 #include<vector> 14 using namespace std; 15 16 typedef unsigned int UI; 17 typedef long long ll; 18 19 UI X,Y,Z; 20 21 UI RNG61() { 22 X=X^(X<<11); 23 X=X^(X>>4); 24 X=X^(X<<5); 25 X=X^(X>>14); 26 UI W=X^(Y^Z); 27 X=Y; 28 Y=Z; 29 Z=W; 30 return Z; 31 } 32 33 const int N = 100005; 34 const unsigned int MOD = (1U<<30); 35 36 int n,m; 37 38 #define LSON (k<<1) 39 #define RSON (k<<1|1) 40 #define MID ((l+r)>>1) 41 42 int mx[N<<2]; 43 44 void update(int k,int l,int r,int ll,int rr,int val) { 45 if(mx[k]>=val) return ; 46 if(l==ll && r==rr) { 47 mx[k]=val; 48 return ; 49 } 50 int mid=MID; 51 if(rr<=mid) update(LSON,l,mid,ll,rr,val); 52 else if(ll>mid) update(RSON,mid+1,r,ll,rr,val); 53 else { 54 update(LSON,l,mid,ll,mid,val); 55 update(RSON,mid+1,r,mid+1,rr,val); 56 } 57 } 58 59 int query(int k,int pos) { 60 int l=1,r=n; 61 int ret=0; 62 while(l!=r) { 63 ret=max(ret,mx[k]); 64 int mid=MID; 65 if(pos<=mid) { 66 r=mid; 67 k=LSON; 68 } else { 69 l=mid+1; 70 k=RSON; 71 } 72 } 73 ret=max(ret,mx[k]); 74 return ret; 75 } 76 77 int main() { 78 int T; 79 cin>>T; 80 while(T--) { 81 cin>>n>>m>>X>>Y>>Z; 82 memset(mx,0,sizeof(mx)); 83 for(int i=1;i<=m;i++) { 84 UI x=RNG61(); 85 UI y=RNG61(); 86 UI w=RNG61(); 87 UI l,r,v; 88 l=min(x%n+1, y%n+1); 89 r=max(x%n+1, y%n+1); 90 while(w>MOD) w-=MOD; 91 update(1,1,n,l,r,w); 92 } 93 ll ans=0; 94 //for(int i=1;i<=n;i++) cerr<<query(1,i)<<‘ ‘; cerr<<endl; 95 for(int i=1;i<=n;i++) ans=ans^((ll)query(1,i)*i); 96 cout<<ans<<endl; 97 } 98 return 0; 99 }
1008 小洛洛
dp 枚举翻转的值域dp就好了
1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <cmath> 5 #include <cstdlib> 6 #include <algorithm> 7 using namespace std; 8 9 template<int BI, int BO> 10 struct IO_ { 11 char bufi[BI + 1], *qi, bufo[BO], *qo; 12 IO_(): qi(bufi + BI), qo(bufo) {} 13 ~IO_() { o_(EOF); } 14 int i_() { 15 if(qi == bufi + BI) bufi[fread(bufi, 1, BI, stdin)] = ‘