CF1829G Hits Different

 

坍塌只与 上面的有关

》》》数组多开+循环时检查

》》》运行时 闪退 基本就是 segment ERROR

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define ddd printf("--------------debug\n");
using namespace std;

ll f[2001][2001],a[4000010],cnt=1,n,T;
void pre()
{
    for(int i=1;i<=2000;i++)//
        {
            for(int j=1;j<=i;j++)
            {
                if(i==1) f[i][j]=1;
                else f[i][j]=cnt*cnt+f[i-1][j]+f[i-1][j-1]-f[i-2][j-1];
                a[cnt]=f[i][j];
                 cnt++;
            }    
        } 
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    
    cin>>T;
    pre();

    while(T--)
    {
        //ll n;
        cin>>n;
        //cout<<n<<'\n';
        cout<<a[n]<<'\n';
    }
    
    return 0;
}
View Code

 

 
 
 
 
 
posted @ 2023-07-24 23:00  JMXZ  阅读(2)  评论(0)    收藏  举报