Noip模拟题解题报告
2018-10-17 11:42
197 查看
Pro
第一次AK。
Sol
站军姿
算是数学题吧,求出两圆的位置关系,然后余弦定理和扇形面积什么的搞搞就行。
#include<iostream> #include<cstdio> #include<cmath> #define rfile(x) freopen("x.in","r",stdin); #define wfine(x) freopen("x.out","w",stdout); using namespace std; const double pi = 3.14159265358979323846264; int T , flag; double x1 , Y1 , r1 , x2 , y2 , r2 , len; inline double mypow(double x , int y) { if(!y) return 1; double t = mypow(x , y>>1); if(y&1) return t*t*x; return t*t; } int jud(double x1 , double Y1 , double r1 , double x2 , double y2 , double r2) { if(len<r1+r2) return 0;//相交 else return 1; } void sol(double x1 , double Y1 , double r1 , double x2 , double y2 , double r2) { len = sqrt(mypow(x1-x2,2)+mypow(Y1-y2,2)); double S1=pi*mypow(r1,2) , S2=pi*mypow(r2,2); if((r1-r2)>=len) { printf("%.3lf\n",S1); return ; } if((r2-r1)>=len) { printf("%.3lf\n",S2); return ; } flag = jud(x1,Y1,r1,x2,y2,r2); if(flag) printf("%.3lf\n",S1+S2); if(!flag) { double a1 , a2 , s1 , s2; a1 = 2*acos((r1*r1+len*len-r2*r2)/(2*r1*len)); a2 = 2*acos((r2*r2+len*len-r1*r1)/(2*r2*len)); s1 = r1*r1*a1/2-r1*r1*sin(a1)/2; s2 = r2*r2*a2/2-r2*r2*sin(a2)/2; printf("%.3lf\n",S1+S2-s1-s2); } } int main() { freopen("A.in","r",stdin); freopen("A.out","w",stdout); scanf("%d",&T); while(T--) { scanf("%lf%lf%lf%lf%lf%lf",&x1,&Y1,&r1,&x2,&y2,&r2); sol(x1,Y1,r1,x2,y2,r2); } return 0; }
对刚
约瑟夫杀人问题,特别水。
#include<iostream> #include<cstdio> using namespace std; int n , t , vis[200005] , kill , opt , cnt; int main() { freopen("B.in","r",stdin); freopen("B.out","w",stdout); scanf("%d%d",&n,&t); while(kill!=n) { if(vis[opt+1]) { opt++; continue; } cnt++; opt++; if(opt>n) opt-=n; if(cnt==t) { cnt = 0; vis[opt] = vis[opt+n] = 1; kill++; } } printf("%d",opt); return 0; }
隔壁
做USACO的时候刷到过一道比这个难的题。
这个还是比较简单的,最大值很容易求,就是每一行每一列的最小值。
至于最小值,分两部分求,先做行再做列,能放到同一行的尽量放就会使答案更小。
放过就打上标记,然后再做列的部分。
#include<iostream> #include<cstdio> using namespace std; long long n , m , a[1005] , b[1005] , ans1 , ans2 , visa[1005] , visb[1005]; inline long long mymin(long long x , long long y) { return x<y?x:y; } int main() { freopen("C.in","r",stdin); freopen("C.out","w",stdout); scanf("%lld%lld",&n,&m); for(int i=1; i<=n; i++) scanf("%lld",&a[i]); for(int i=1; i<=m; i++) scanf("%lld",&b[i]); for(int i=1; i<=n; i++) { visa[i] = 1; long long res = 1e9 , pot = 0; for(long long j=1; j<=m; j++) { if(b[j]>=a[i]) { if(b[j]<res&&!visb[j]) { res = b[j]; pot = j; } } ans2 += mymin(a[i],b[j]); } if(res == a[i]) visb[pot] = 1; ans1 += a[i]; } for(int i=1; i<=m; i++) { if(visb[i]) continue; ans1 += b[i]; } printf("%lld %lld",ans1,ans2); return 0; }阅读更多
相关文章推荐
- NOIP模拟题 kun 栈 贪心 解题报告
- NOIP2013 火柴排队 解题报告(贪心+逆序对)
- NOIP2014提高组D.发射器选址(解题报告)
- NOIP2000 解题报告
- NOIP2008 普及组T3 传球游戏 解题报告-S.B.S.
- hdu 5319 - Painter(模拟题)解题报告
- NOIP 2008 传纸条 解题报告
- Luogu1967 [NOIP2013] 货车运输 解题报告【Kruskal】【LCA】【倍增】
- NOIP2007 T1奖学金 解题报告-S.B.S.
- NOIP2008 普及组T1 ISBN号码 解题报告-S.B.S.
- [NOIP2010] 关押罪犯-解题报告
- 2016.7.15 NOIP2014模拟试题解题报告(又名:方克顺和他的正余弦朋友们(
- NOIP2008解题报告
- NOIP2006解题报告PJ
- [Noip2016]换教室 解题报告
- 【noip2013】【提高组】【Day2】【解题报告】
- NOIP2010普及组 导弹拦截(重庆一中高2018级信息学竞赛测验3) 解题报告
- NOIp2015提高组 解题报告
- NOIP2014 解题报告·水渣记
- NOIP2015解题报告 By ljt12138