• 【XSY2851】蛋糕 数学


    题目大意

      有一个边长为 (1) 的正 (n) 边形,你要把这个正 (n) 边形放到一个正 (m) 边形里面,且两个多边形的中心重合。

      问你这个正 (m) 边形的边长最小是多少。

      (n,mleq {10}^9)

    题解

      对于一种合法的方案,把这个正 (n) 边形旋转 (frac{2pi}{m}) 度之后也能放到这个正 (m) 边形里面。

      那么把所有 (frac{m}{gcd(n,m)}) 种多边形拼到一起之后就会得到一个 (operatorname{lcm}(n,m)) 边形。

      现在我们要把正 (operatorname{lcm}(n,m)) 边形塞进一个正 (m) 边形。

      这就很简单了。

      这个正 (m) 边形的每条边对准这个正 (operatorname{lcm}(n,m)) 边形就好了。

    代码

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cstdlib>
    #include<ctime>
    #include<utility>
    #include<functional>
    #include<cmath>
    #include<vector>
    //using namespace std;
    using std::min;
    using std::max;
    using std::swap;
    using std::sort;
    using std::reverse;
    using std::random_shuffle;
    using std::lower_bound;
    using std::upper_bound;
    using std::unique;
    using std::vector;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    typedef std::pair<int,int> pii;
    typedef std::pair<ll,ll> pll;
    void open(const char *s){
    #ifndef ONLINE_JUDGE
    	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
    #endif
    }
    void open2(const char *s){
    #ifdef DEBUG
    	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
    #endif
    }
    int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
    void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
    int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
    int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
    const db pi=acos(-1);
    ll gcd(ll a,ll b)
    {
    	return b?gcd(b,a%b):a;
    }
    ll n,m;
    int main()
    {
    	open("b");
    	scanf("%lld%lld",&n,&m);
    	db r=1./2/sin(pi/n);
    	n=n/gcd(n,m)*m;
    	r*=cos(pi/n);
    	db ans=r*tan(pi/m)*2;
    	printf("%.10f
    ",ans);
    	return 0;
    }
    
  • 相关阅读:
    排版字号对应多少pt
    C# 定义常量 两种实现方法
    HttpApplication 类,HttpApplicationState 类
    [ASP.net教程]ASP.NET保存信息总结(Application、Session、Cookie、ViewState和Cache等)
    sqlserver 汉字转拼音(转载)
    几个不错的echarts +百度地图 案例
    ECharts 实现地图散点图上(转载)
    ECharts 散点图+百度地图(案例转载)
    SQL统计部门人数,人数为0的部门也要显示出来
    待看文档
  • 原文地址:https://www.cnblogs.com/ywwyww/p/9767466.html
Copyright © 2020-2023  润新知