Codeforces Beta Round #1
来源:互联网 发布:美工的就业前景 编辑:程序博客网 时间:2024/05/22 01:54
题意:给你一个矩形的常和宽,以及边长为a的正方形砖块,用砖块去铺这个矩形,允许重叠,直接用ceil函数
#include <cstdio>#include <cmath>int main(){ int m,n,a; scanf("%d%d%d",&m,&n,&a); printf("%.lf\n",ceil(m*1.0/a)*ceil(n*1.0/a)); return 0;}
题意:类似于Excel里面的表示方法,用来转换两种表示方法之间的编码,直接暴力。。。
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>#include <stack>using namespace std;char s[20];bool judge(char s[]){ int l=strlen(s); int ans=0; for(int i=1;i<l;i++) if((s[i]>='0'&&s[i]<='9')&&(s[i-1]>='A'&&s[i-1]<='Z')) ans++; if(ans==2) return true; return false;}int main(){ int test; //freopen("a.txt","r",stdin); //freopen("b.txt","w",stdout); scanf("%d",&test); while(test--) { scanf("%s",s); if(judge(s)) { int l=strlen(s); int r=0,c=0; int rr=1,cc=1; int i,j; for(i=l-1;i>=0;i--) { if(s[i]>='A'&&s[i]<='Z') break; if(s[i]>='0'&&s[i]<='9') { c+=cc*(s[i]-'0'); cc*=10; } }/* for(;i>=0;i--) { if(s[i]>='A'&&s[i]<='Z') continue; if(s[i]>='0'&&s[i]<='9') break; } i++;*/ for(j=i-1;j>=0;j--) { if(s[j]>='A'&&s[j]<='Z') break; if(s[j]>='0'&&s[j]<='9') { r+=rr*(s[j]-'0'); rr*=10; } } stack<char>st; while(!st.empty()) st.pop(); while(c) { int num=c%26; if(num==0) { st.push('Z'); c--; } else st.push(num-1+'A'); c/=26; } while(!st.empty()) { printf("%c",st.top()); st.pop(); } printf("%d\n",r); } else { int r=0,c=0; int rr=1,cc=1; int i,j,l=strlen(s); stack<char>st; stack<char>nt; while(!nt.empty()) nt.pop(); while(!st.empty()) st.pop(); for(i=0;i<l;i++) { if(s[i]>='0'&&s[i]<='9') break; st.push(s[i]); } for(j=i;j<l;j++) { nt.push(s[j]); } while(!st.empty()) { c+=cc*(st.top()-'A'+1); cc*=26; st.pop(); } while(!nt.empty()) { r+=rr*(nt.top()-'0'); rr*=10; nt.pop(); } printf("R%dC%d\n",r,c); } } return 0;}
题意:给你三个点的坐标,求由这三个点得到的正多边形的面积,由于不知道这个正多边形有多少条边,以及不清楚由这n个等腰三角形的每个三角形的面积,开始我想的方法是求由这三个点组成的三角形的外接圆及半径,然后每条边于外心组成的三角形中圆心角最小的那个三角形对应的那条边应该就是这个正多边形组成的基本元素,然后WA了,原因是(思路错了!)
换种方法做,假使开始是3边形,这种与圆心组成的角中,如果每个角都满足能够满足这些角围成一圈就退出,直到n边形为止,这样一直枚举下去,找到合适的情况就break
// WA 了,思路跪了(感谢woshiren01指出错误)所以跪了#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#define PI 3.141592653589793struct point{ double x; double y;};point ans,p[3];struct Line{ point a; point b; double distance; double jiao;};point intersection(Line u,Line v){ point res=u.a; double k=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))/((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x)); res.x+=(u.b.x-u.a.x)*k; res.y+=(u.b.y-u.a.y)*k; return res;}point circumcenter(point a,point b,point c){ Line u,v; u.a.x=(a.x+b.x)/2; u.a.y=(a.y+b.y)/2; u.b.x=u.a.x-a.y+b.y; u.b.y=u.a.y+a.x-b.x; v.a.x=(a.x+c.x)/2; v.a.y=(a.y+c.y)/2; v.b.x=v.a.x-a.y+c.y; v.b.y=v.a.y+a.x-c.x; return intersection(u,v);}bool cmp(Line xx,Line yy){ return xx.jiao>yy.jiao;}double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}double cal(Line ll){ double xx=dis(ll.a,ans); double yy=dis(ll.b,ans); double zz=ll.distance; return (xx*xx+yy*yy-zz*zz)/2/xx/yy;}double area(double x0,double y0,double x1,double y1,double x2,double y2){ return (x0*y1+x2*y0+x1*y2-x2*y1-x0*y2-x1*y0)/2.0;}int main(){ for(int i=0;i<3;i++) scanf("%lf%lf",&p[i].x,&p[i].y); ans=circumcenter(p[0],p[1],p[2]); Line x[3]; x[0].distance=dis(p[1],p[2]); x[1].distance=dis(p[0],p[2]); x[2].distance=dis(p[0],p[1]); x[0].a=p[1],x[0].b=p[2]; x[1].a=p[0],x[1].b=p[2]; x[2].a=p[0],x[2].b=p[1]; for(int i=0;i<3;i++) x[i].jiao=cal(x[i]); sort(x,x+3,cmp); //printf("%lf....%lf\n",x[0].a.x,x[0].a.y); //printf("%lf....%lf\n",x[0].b.x,x[0].b.y); //printf("%lf\n",acos(x[0].jiao)); double ccc=2*PI/acos(x[0].jiao); //printf("%lf\n",ccc); double mmmm=ccc*area(ans.x,ans.y,x[0].a.x,x[0].a.y,x[0].b.x,x[0].b.y); mmmm<0?(mmmm*=-1):1; printf("%.8lf\n",mmmm); return 0;}
换方法之后,果然过了。
#include <cstdio>#include <iostream>#include <cmath>#include <algorithm>using namespace std;#define pi 3.1415926#define eps 10e-3typedef struct point{ double x,y;};double area(double x0,double y0,double x1,double y1,double x2,double y2){ return 0.5*fabs(x0*y1+x2*y0+x1*y2-x2*y1-x0*y2-x1*y0);}double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}point p[3];bool is_ok(int n,double jiao){ double cnt=n*jiao/pi; double pnt=floor(cnt+eps); if(cnt-pnt<eps) return true; return false;}int main(){ for(int i=0;i<3;i++) scanf("%lf%lf",&p[i].x,&p[i].y); double a=dis(p[0],p[1]); double b=dis(p[0],p[2]); double c=dis(p[1],p[2]); double A=acos((b*b+c*c-a*a)/2/b/c); double B=acos((a*a+c*c-b*b)/2/a/c); double C=acos((b*b+a*a-c*c)/2/b/a); double r=a*b*c/area(p[0].x,p[0].y,p[1].x,p[1].y,p[2].x,p[2].y)/4; //double jiao=max(A,max(B,C)); 开始我觉得下面的is_ok函数只要判断jiao就可以了// 其实还是会WA 第五组数据。。。WA的时候答案是输出的两倍,Wa的厉害了 int n; for(n=3;n<=100;n++) if(is_ok(n,A)&&is_ok(n,B)&&is_ok(n,C)) break; double tag=2*pi/n; double Area=n*r*r*sin(tag)/2; printf("%.8lf\n",Area); return 0;}
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1
- Codeforces Beta Round #1 练习
- Codeforces Beta Round #1 ABC
- Codeforces Beta Round #1(A,B)
- Codeforces Beta Round #83 (Div. 1 Only)
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #1 A题
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #1 A - Theatre Square
- Codeforces Beta Round #1 A. Theatre Square
- hdu 4255
- iphone线程中使用异步网络的问题,以及如何用NSRunLoop来解决
- iOS 推送通知详解
- iPhone开发学习笔记——Core Data 框架及运作过程和设计的类
- 产品设计“九步法”
- Codeforces Beta Round #1
- PL/SQL Developer连接oracle数据库方法
- Android有效解决加载大图片时内存溢出的问题
- UITextView 实现 placeholder 及隐藏键盘
- iOS本地通知和远程通知
- ContextImpl getSysteService
- 将工程转成 arc
- 阻塞和非阻塞通信
- 在CodeBlocks环境下使用boost库