Codeforces Beta Round #1
A题,水题。
B题也是水题,弄的比较麻烦,前几天队内赛见过,水题怎么水都能过。
C题
题意:给出正n边形上的三个点,求最小的正n边形的面积。
以前貌似见过此题。思路也没什么进展,就是枚举n,通过旋转a,判断b c是否在多边形上。感觉是水过的,改了改eps就过了,看别人代码,还有神奇的gcd的做法。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <queue> #include <algorithm> using namespace std; int s[30]; int que[30]; void judge(int x) { int num,n,i; for(i = 1;i <= 10;i ++) { if(s[i] >= x) break; x -= s[i]; } memset(que,0,sizeof(que)); n = i; num = 0; x--; while(x) { que[num++] = x%26; x /= 26; } for(i = n-1;i >= 0;i --) { printf("%c",que[i]+'A'); } return ; } void fun1(char *str) { int a,b,i; a = b = 0; int len; len = strlen(str); for(i = 1;i < len;i ++) { if(str[i] == 'C') break; a = a*10 + (str[i]-'0'); } for(i = i+1;i < len;i ++) b = b*10 + (str[i]-'0'); judge(b); printf("%d\n",a); } void fun2(char *str) { int a = 0,i,j; int len; len = strlen(str); for(i = 0;i < len;i ++) { if(str[i] <= '9'&&str[i] >= '0') break; } int num = 0; for(j = i-1;j >= 0;j --) a += s[num++]*(str[j] - 'A' + 1); printf("R"); for(;i < len;i ++) printf("%c",str[i]); printf("C%d\n",a); } int main() { int t,len,i; char str[1000]; scanf("%d",&t); s[0] = 1; for(i = 1;i <= 10;i ++) s[i] = s[i-1]*26; while(t--) { scanf("%s",str); len = strlen(str); if(str[0] == 'R') { int flag = 0,z = 0; for(i = 1;i < len;i ++) { if(str[i] == 'C'&&i >= 2) flag ++; else if(str[i] <= 'Z'&&str[i] >= 'A') z = 1; } if(flag == 1&&z == 0) fun1(str); else fun2(str); } else fun2(str); } return 0; }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <queue> #include <cmath> #include <algorithm> using namespace std; #define PI 3.1415926 #define eps 1e-3 struct point { double x,y; }; struct line { point a,b; }; point intersection(line u,line v) { point ret = u.a; double t = ((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)); ret.x += (u.b.x-u.a.x)*t; ret.y += (u.b.y-u.a.y)*t; return ret; } 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); } point Rotate(point p,double angle) { point res; res.x = p.x * cos(angle) - p.y*sin(angle); res.y = p.x * sin(angle) + p.y*cos(angle); return res; } int judge(point a,point b) { double t; t = a.x - b.x; if(t < 0) t = -t; if(t > eps) return 0; t = a.y - b.y; if(t < 0) t = -t; if(t > eps) return 0; return 1; } int main() { int i,j,n; point a,b,c,r,d; point p[201]; scanf("%lf%lf",&a.x,&a.y); scanf("%lf%lf",&b.x,&b.y); scanf("%lf%lf",&c.x,&c.y); r = circumcenter(a,b,c); d.x = a.x - r.x; d.y = a.y - r.y; for(i = 3;i <= 100;i ++) { int num = 0; p[0] = a; for(j = 1;j < i;j ++) { p[j] = Rotate(d,2*PI*j/i); p[j].x += r.x; p[j].y += r.y; if(judge(p[j],b)) num ++; if(judge(p[j],c)) num ++; } if(num == 2) break; } n = i; double s1,s2; s1 = s2 = 0; for(i = 0;i < n;i ++) { s1 += p[(i+1)%n].y*p[i].x; s2 += p[(i+1)%n].y*p[(i+2)%n].x; } printf("%.7lf",fabs(s1-s2)/2); return 0; }