Codeforces Beta Round #1
http://codeforces.com/contest/1
A
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<bits/stdc++.h> 2 using namespace std; 3 const long long MOD=1e9+7; 4 5 int main(){ 6 long long n,m,a; 7 cin>>n>>m>>a; 8 long long aa=n/a; 9 if(n%a) aa++; 10 long long bb=m/a; 11 if(m%a) bb++; 12 cout<<aa*bb<<endl; 13 }
B
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<bits/stdc++.h> 2 using namespace std; 3 void ss(int col){ 4 if(col>26) ss((col-1)/26); 5 cout<<char((col-1)%26+'A'); 6 } 7 8 int main(){ 9 int n; 10 string str; 11 cin>>n; 12 while(n--){ 13 cin>>str; 14 int flag=-1; 15 if(str[0]=='R'&&str[1]>='0'&&str[1]<='9'){ 16 int i; 17 for(i=1;i<str.length();i++){ 18 if(str[i]=='C'){ 19 flag=i; 20 break; 21 } 22 } 23 } 24 if(flag==-1){ 25 int row=0,col=0; 26 for(int i=0;i<str.length();i++){ 27 if(str[i]>='A'&&str[i]<='Z'){ 28 row=row*26+str[i]-'A'+1; 29 } 30 else{ 31 col=col*10+str[i]-'0'; 32 } 33 } 34 cout<<"R"<<col<<"C"<<row<<endl; 35 } 36 else{ 37 int row=0,col=0; 38 for(int i=1;i<flag;i++){ 39 row=row*10+str[i]-'0'; 40 } 41 for(int i=flag+1;i<str.length();i++){ 42 col=col*10+str[i]-'0'; 43 } 44 ss(col); 45 cout<<row<<endl; 46 } 47 } 48 }
C
参考博客:https://www.luogu.org/problemnew/solution/CF1C
知识点:由于圆心角的度数皆为正多边形中心角度数的倍数,可以通过求圆心角度数的最大公约数求出正多边形的中心角度数t
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<bits/stdc++.h> 2 using namespace std; 3 const double eps=1e-2; 4 const double Pi=acos(-1.0); 5 struct Point{ 6 double x,y; 7 }p[3]; 8 9 double dist(int i,int j){ 10 return sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y)); 11 } 12 13 double gcd(double a,double b){ 14 if(fabs(a)<eps) return b; 15 if(fabs(b)<eps) return a; 16 return gcd(b,fmod(a,b)); 17 } 18 19 int main(){ 20 double len[3],angle[3]; 21 for(int i=0;i<3;i++){ 22 scanf("%lf%lf",&p[i].x,&p[i].y); 23 } 24 double p=0; 25 for(int i=0;i<3;i++){ 26 len[i]=dist(i,(i+1)%3); 27 p+=len[i]; 28 } 29 p/=2; 30 double S=sqrt(p*(p-len[0])*(p-len[1])*(p-len[2])); 31 double R=len[0]*len[1]*len[2]/(4*S); 32 for(int i=0;i<2;i++){ 33 angle[i]=2*asin(len[i]/(2*R)); 34 } 35 angle[2]=2*Pi-angle[0]-angle[1];///防止误差 36 double t=gcd(angle[0],gcd(angle[1],angle[2]));//求圆心角 37 double ans=Pi*R*R*sin(t)/t; 38 printf("%7f\n",ans); 39 40 41 }
posted on 2019-01-19 20:36 Fighting_sh 阅读(143) 评论(0) 编辑 收藏 举报