Untitled
unknown
c_cpp
2 years ago
1.8 kB
9
Indexable
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back #define fd(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) #define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) #define f(i, n) fd(i, 0, n) #define fn(i, n) FORN(i, 1, n) const ll int mod = 10000000007; const ll int N= 1e6; #define cyes cout<<"YES"<<endl #define cno cout<<"NO"<<endl using namespace std; using vlli = vector< ll int >; using vi = vector < int >; #define m1e9 1000000007 #define int long long int #define endl "\n" int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int dp[2023*1012 + 1]; dp[1]=1; int st =2; int j=2; int i; while(j<=2023*1012) { i=0; while(i<st) { if(i==0) { dp[j]=(j*j)+ dp[j-st+1]; // cout<<j<<" "<<j-st+1<<" "<<dp[j]<<endl; } else if(i==st-1) { dp[j]=(j*j)+ dp[j-st]; // cout<<j<<" "<<j-st<<" "<<dp[j]<<endl; } else { dp[j]=(j*j)+ dp[j-st]+dp[j-st+1] - dp[j - 2*st + 2]; // cout<<j<<" "<<j-st<<" "<<j-st+1<<" "<<dp[j]<<endl; } // cout<<i<<" "<<j<<" "<<dp[j]<<endl; j++; i++; if(j==2023*1012)break; } if(j==2023*1012)break; st++; } int t; cin>>t; while(t--) { int n; cin>>n; cout<<dp[n]<<endl; } }
Editor is loading...