六一儿童节补坑快乐

C2. Not So Simple Polygon Embedding

time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
The statement of this problem is the same as the statement of problem C1. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.

You are given a regular polygon with 2⋅n vertices (it’s convex and has equal sides and equal angles) and all its sides have length 1. Let’s name it as 2n-gon.

Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.

You can rotate 2n-gon and/or the square.

Input
The first line contains a single integer T (1≤T≤200) — the number of test cases.

Next T lines contain descriptions of test cases — one per line. Each line contains single odd integer n (3≤n≤199). Don’t forget you need to embed 2n-gon, not an n-gon.

Output
Print T real numbers — one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn’t exceed 10−6.

Example
inputCopy
3
3
5
199
outputCopy
1.931851653
3.196226611
126.687663595

思路

数学题,推出数学公式的话就很好办了。和C1其实类似,就是加强了一下条件。

#include<bits/stdc++.h>
using namespace std;
int t,n;
int main(){
	cin>>t;
	while(t--){
		cin>>n;
		printf("%.7f\n",1.0/(2.0*sin(3.1415926535898/(4.0*n))));
	}
	return 0;
}

D. Constructing the Array

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are given an array a of length n consisting of zeros. You perform n actions with this array: during the i-th action, the following sequence of operations appears:

Choose the maximum by length subarray (continuous subsegment) consisting only of zeros, among all such segments choose the leftmost one;
Let this segment be [l;r]. If r−l+1 is odd (not divisible by 2) then assign (set) a[l+r2]:=i (where i is the number of the current action), otherwise (if r−l+1 is even) assign (set) a[l+r−12]:=i.
Consider the array a of length 5 (initially a=[0,0,0,0,0]). Then it changes as follows:

Firstly, we choose the segment [1;5] and assign a[3]:=1, so a becomes [0,0,1,0,0];
then we choose the segment [1;2] and assign a[1]:=2, so a becomes [2,0,1,0,0];
then we choose the segment [4;5] and assign a[4]:=3, so a becomes [2,0,1,3,0];
then we choose the segment [2;2] and assign a[2]:=4, so a becomes [2,4,1,3,0];
and at last we choose the segment [5;5] and assign a[5]:=5, so a becomes [2,4,1,3,5].
Your task is to find the array a of length n after performing all n actions. Note that the answer exists and unique.

You have to answer t independent test cases.

Input
The first line of the input contains one integer t (1≤t≤104) — the number of test cases. Then t test cases follow.

The only line of the test case contains one integer n (1≤n≤2⋅105) — the length of a.

It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 (∑n≤2⋅105).

Output
For each test case, print the answer — the array a of length n after performing n actions described in the problem statement. Note that the answer exists and unique.

Example
inputCopy
6
1
2
3
4
5
6
outputCopy
1
1 2
2 1 3
3 1 2 4
2 4 1 3 5
3 4 1 5 2 6

思路

补的第二题有点绕。这里第一次运用pair,将两个数组成一队。
相当于是模拟,记下数的顺序再对应回去。这里根据区间长度判断出了写数的顺序。

#include <bits/stdc++.h>
using namespace std;
int a[200005],i,n,t;
pair<int,int> b[200005];
void d(int l,int r){
	if(l>r)return;
    int m=(l+r)/2;
	b[m]={l-r,m};
	d(l,m-1);
	d(m+1,r);
}
int main() {
    cin>>t;
    while(t--){
    	cin>>n;
        d(1,n);
        sort(b+1,b+1+n);
        for (i=1;i<=n;i++) a[b[i].second]=i;
		for (i=1;i<=n;i++) cout<<a[i]<<" ";
        puts("");
    }
}

写在六一的话

想看题解的直接跳到上一部分好了。以下的话,只是我自己个人的一些经历感受,各位看官切莫当真,喷子请出门,不送。
既然是六一节,就要干点有意义的事情。
今天思考了好久打CF的意义,以及CF的分的意义。听说最近CF特别容易涨分。个人是只想把CF作为一种训练,而不是某种奇奇怪怪的能力体现。所以呢,未来一周也不会再开新的CF了。重心将放在补题和真正学习知识点上面。从初中走到现在,真的从功利转为一种兴趣了,我认为编程可以让我的脑袋定期训练一下,而且我认为一切的底线是它让我快乐。如果让我熬夜到一两点,参加CF,就为了上1600,1800,说实在的,我不快乐,我感受到的绝大多数是身体的疲惫。博主近视度已经四位数了,任何熬夜,特别是盯着电脑的熬夜都是痛苦的。我想这也不算是偷懒或是逃避,我的训练强度我自己知道,我心里想要的也知道。既然别人不能感同身受,那我就要自己掌握命运。
最近也参加了一些活动,得到了和谷歌员工交流的机会。关于这家公司,以及这一类公司也有了一些新的看法。关于以后就业的选择,也是有了更多的想法。
零零碎碎,罗里吧嗦说了很多,其实总结起来就是,在听取外部意见的同时,我还是希望可以遵循本心,无愧自己。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值