zoukankan      html  css  js  c++  java
  • CF1

    A

    A

    给定(n*m)的网格,求最少用多少块(k*k)的砖可以铺满整个网格,砖不能重叠,可以铺到外面

    答案为(leftlceildfrac{n}{k} ight ceil*leftlceildfrac{m}{k} ight ceil)

    #include<bits/stdc++.h>
    using namespace std;
    namespace red{
    #define y1 qwq
    #define int long long
    #define eps (1e-6)
    	inline int read()
    	{
    		int x=0;char ch,f=1;
    		for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    		if(ch=='-') f=0,ch=getchar();
    		while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    		return f?x:-x;
    	}
    	int n,m,a;
    	inline void main()
    	{
    		n=read(),m=read(),a=read();
    		cout<<((n-1)/a+1)*((m-1)/a+1)<<endl;
    	}
    }
    signed main()
    {
    	red::main();
    	return 0;
    }
    

    B

    B

    给定二十六进制字母转数字,或数字转字母

    模拟题,真烦

    注意事项在注释里面

    	#include<bits/stdc++.h>
    using namespace std;
    namespace red{
    #define y1 qwq
    #define int long long
    #define eps (1e-6)
    	inline int read()
    	{
    		int x=0;char ch,f=1;
    		for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    		if(ch=='-') f=0,ch=getchar();
    		while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    		return f?x:-x;
    	}
    	int n,x,y,len,t;
    	char s[100010];
    	int st[1000010],top;
    	inline void main()
    	{
    		n=read();
    		while(n--)
    		{
    			scanf("%s",s+1);
    			x=y=0;
    			len=strlen(s+1);
    			bool flag=0;
    			for(int i=1;i<=len;++i)//不能只判断第一位i,要判断后面有没有C
    			{
    				if(s[i]<'A'||s[i]>'Z')
    				{
    					int j=i+1;
    					while(j<=len)
    					{
    						if(s[j]=='C') flag=1;
    						++j;
    					}
    					break;
    				}
    			}
    			if(flag)
    			{
    				
    				t=2;
    				while(s[t]>='0'&&s[t]<='9') x=(x<<1)+(x<<3)+s[t]-'0',++t;
    				++t;
    				while(t<=len) y=(y<<1)+(y<<3)+s[t]-'0',++t;
    				while(y)
    				{
    					st[++top]=y%26;
    					if(!st[top]) st[top]=26;//注意这里,答案为0应该是Z,上一位应该-1
    					y=y/26-(st[top]==26);
    				}
    				while(top)
    				{
    					cout<<(char)(st[top--]+'A'-1);
    				}
    				top=0;
    				cout<<x<<endl;
    			}
    			else
    			{
    				
    				t=1;
    				while(s[t]>='A'&&s[t]<='Z') x=x*26+s[t]-'A'+1,++t;
    				
    				while(t<=len) y=(y<<1)+(y<<3)+s[t]-'0',++t;
    				
    				cout<<'R'<<y<<'C'<<x<<endl;
    				
    			}
    		}
    	}
    }
    signed main()
    {
    	red::main();
    	return 0;
    }
    

    C

    C

    有一个正多边形,给定三个顶点,求这个正多边形最小面积,边数不超过(100)

    计算几何题目……

    显然给定的三个点在正多边形的外接圆上,我们求出三角形的边长(a,b,c)

    然后用海伦公式(S=sqrt{p*(p-a)*(p-b)*(p-c)}(p=frac{a+b+c}{2}))得到面积

    由于(S=frac{1}{2}absin(C)),且(frac{c}{sin(C)}=2r),得到(r=frac{abc}{4S})

    由于三角形每条边的圆心角都是中心角的倍数(正多边形相邻两点构成的圆心角),所以每个三角形三个角度的最大公约数即为边数最少的正多边形中心角(可以证明边数越少面积越小)

    中心角求法:

    (cos(C)=frac{a^2+b^2-c^2}{2ab}=frac{r^2+r^2-c^2}{2r^2}=1-frac{c^2}{2r^2})

    然后用反三角函数求出(C)的角度

    为了保证精度,最后一个角度用减法求出

    然后(gcd)求出中心角(t)

    注意这个实数(gcd)(eps)不能取的太小,否则会让边数大于(100)

    那么每个三角形面积为(frac{r^2sin(t)}{2}),共有(frac{2pi}{t})个三角形,总面积为(frac{pi r^2sin(t)}{t})

    #include<bits/stdc++.h>
    using namespace std;
    namespace red{
    #define y1 qwq
    #define int long long
    	inline int read()
    	{
    		int x=0;char ch,f=1;
    		for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    		if(ch=='-') f=0,ch=getchar();
    		while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    		return f?x:-x;
    	}
    	const double pi=acos(-1.0),eps=1e-2;
    	struct node
    	{
    		double x,y,len,d;
    	}p[5];
    	double t,s,r;
    	inline double dis(int i,int j)
    	{
       		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));
    	}
    	inline double gcd(double a,double b)//实数gcd
    	{
    		if(fabs(b)<eps) return a;
    		if(fabs(a)<eps) return b;
    		return gcd(b,fmod(a,b));
    	}
    	inline void main()
    	{
    		for(int i=0;i<3;++i)
    			scanf("%lf%lf",&p[i].x,&p[i].y);
    		for(int i=0;i<3;++i)
    		{
    			p[i].len=dis(i,(i+1)%3);//求边长
    			t+=p[i].len;
    		}
    		t/=2;
    		s=sqrt(t*(t-p[0].len)*(t-p[1].len)*(t-p[2].len));//海伦公式
    		r=p[0].len*p[1].len*p[2].len/(4*s);//外接圆半径
    		for(int i=0;i<2;++i) p[i].d=acos(1-p[i].len*p[i].len/(2*r*r));//圆心角
    		p[2].d=2*pi-p[0].d-p[1].d;//最后一个用减法
    		t=gcd(p[0].d,gcd(p[1].d,p[2].d));//最大公约数
    		printf("%.6lf
    ",(pi*r*r*sin(t))/t);
    	}
    }
    signed main()
    {
    	red::main();
    	return 0;
    }
    
  • 相关阅读:
    window共享文件夹
    java之Jsoup爬取网页内容
    休闲电影网站
    Java常用工具包
    12个非常适合做外包项目的开源后台管理系统
    Python 创建项目时配置 Scrapy 自定义模板
    Python 之 scrapy 创建项目
    Python几种主流框架
    在线工具
    twisted.internet.error.CannotListenError: Couldn't listen on 127.0.0.1:6073: [WinError 10048] 通常每个套接字地址(协议/网络地址/端口)只允许使用一次
  • 原文地址:https://www.cnblogs.com/knife-rose/p/12219550.html
Copyright © 2011-2022 走看看