首页 > 其他分享 >E. Cells Arrangement

E. Cells Arrangement

时间:2024-05-04 19:56:15浏览次数:6  
标签:code int 题解 Cells cin Arrangement

原题链接

题解

  • 集合内元素最大不超过 \(2n-1\) ,最小不小于 \(1\)
  • 如果按对角线排列,则可以得到所有偶数,把其中一颗棋子往旁边移,可以得到所有奇数

code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        for(int i=1;i<=n-2;i++) cout<<i<<" "<<i<<endl;
        printf("%d %d\n%d %d\n\n",n-1,n,n,n);
    }
    return 0;
}

标签:code,int,题解,Cells,cin,Arrangement
From: https://www.cnblogs.com/pure4knowledge/p/18172613

相关文章

  • CF1968E.Cells Arrangement-构造(给个和题解不同的做法)
    link:https://codeforces.com/problemset/problem/1968/E题意:需要构造一个\(n\timesn\)的棋盘,在上面放\(n\)枚棋子,设集合\(\mathcal{H}\)表示两两之间曼哈顿距离构成的集合,要让\(|\mathcal{H}|\)最大。给出放棋子的方案。首先说说题解的做法…考虑把距离为奇数和偶数的......
  • Aspose Cells 单元格 格式
    Aspose单元格格式编号///<summary>///单元格样式编号///0GeneralGeneral///1Decimal0///2Decimal0.00///3Decimal#,##0///4Decimal#,##0.00///5Currency$#,##0;$-#,##0///6Currency$#,##0;[Red]$-#,##0///7Currency$#,##0.00;$-#,#......
  • CodeForces 838D Airplane Arrangements
    洛谷传送门CF传送门考虑加入第\(n+1\)个位置,这样座位构成了一个环。每个位置被覆盖的概率相等,为\(\frac{m}{n+1}\),然后算出概率再乘方案数就行了。code//Problem:D.AirplaneArrangements//Contest:Codeforces-IndiaHacks2ndElimination2017(unofficial,......
  • [945] Replacing a string in all cells of a Pandas DataFrame
    ToreplaceastringinallcellsofaPandasDataFrame,wecanusethe str.replace()method,whichallowsustoperformstringreplacementsoneachelementofacolumn. Hereisanexample:importpandasaspd#CreateasampleDataFramedata={'Co......
  • 将CSS中的cellpadding和cellspacing设置为?
    内容来自DOChttps://q.houxu6.top/?s=将CSS中的cellpadding和cellspacing设置为?在HTML表格中,可以使用CSS设置cellpadding和cellspacing属性,如下所示:<style>table{cellspacing:1;cellpadding:1;}</style><table></table>这样就可以使用CS......
  • CF367C Sereja and the Arrangement of Numbers
    这题首先上来会发现题目中的很多信息都是假的,核心就是问要构造一个\(x\)个点的完全图至少要多长的序列我们把序列中相邻的两个元素看作图上的一条边,则可以把问题转化为:给一个\(x\)个点的完全图,问至少要走多长的路径才可以遍历图中的所有边至少一次简单讨论下会发现当\(x\)为奇数......
  • CF908D New Year and Arbitrary Arrangement 题解
    NewYearandArbitraryArrangement思路:期望题果然还是恶心呀!我们设\(f[i][j]\)表示当串中有\(i\)个\(a\)和\(j\)个\(ab\)时的方案数。为了方便,设\(A=\dfrac{P_a}{P_a+P_b},B=\dfrac{P_b}{P_a+P_b}\)。显然,可以这样转移:\[f[i][j]=f[i+1][j]\timesA+f[i][i+j]\ti......
  • 题解 P9695【[GDCPC2023] Traveling in Cells】
    显然,询问的答案即为\(x\)所在的极长的满足颜色均在\(\mathbb{A}\)内的连续段的权值和。如果我们能维护对颜色的单点修改,以及求出某个位置所在极长连续段的左右端点\(l,r\),只需要树状数组即可求出答案。一个朴素的想法是对每种颜色开一棵线段树,单点修改是平凡的,极长连续段左......
  • String Rearrangement in Phantom
    先考虑一个\(O(nq)\)的暴力,令\(s_{1}=S[l_{1},r_{1}],s_{2}=S[l_{2},r_{2}]\),令\(t=\operatorname{rev}(s_{2})\),则我们仅需求\(s_{1}=A+B+C,t=\operatorname{rev}(A)+B+\operatorname{rev}(C)\)的数量,对于每一个前缀和后缀求出其翻转是否与其相等即可,这个可以通过\(\text{......
  • CF838D Airplane Arrangements 题解
    题意一架飞机有\(n\)个座位排成一列,有\(m\)名乘客(\(m\leqn\))依次上飞机。乘客会选择一个目标座位(两人可以选同一个目标座位),然后选择从前门或者后门上飞机,上飞机后,他们会走到自己的目标座位,如果目标座位已经有人坐了,他们会继续往前走,在走到第一个空位后坐下。如果走到最后......