D.Link with Equilateral Triangle
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
cout<<"No"<<endl;
}
return 0;
}
F.BIT Subway
#include<bits/stdc++.h>
using namespace std;
typedef pair<int ,int>PII;
typedef long long ll;
int ans,sum;
const int N=1e5+10;
double d[N];
int n;
int main()
{
int t;
cin>>t;
while(t--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lf",&d[i]);
double sum=0;
double sum1=0;
for(int i=1;i<=n;i++)
{
sum1+=d[i];
}
if(sum1>100&&sum1<=225)
{
sum1=100+(sum1-100)*0.8;
}else if(sum1>225)
{
sum1=200+(sum1-225)*0.5;
}
for(int i=1;i<=n;i++)
{
if(sum>=100&&sum<200)
sum+=d[i]*0.8;
else if(sum>=200)
sum+=d[i]*0.5;
else
sum+=d[i];
}
printf("%.3lf %.3lf\n",sum1,sum);
}
return 0;
}
G.Climb Stairs
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
ll n,k,a[N];
ll s[N];
int main()
{
int t;
cin>>t;
while(t--)
{
scanf("%d%d%d",&n,&a[0],&k);
s[0]=a[0];
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
s[i]=s[i-1]+a[i];
}
int f=1;
ll sum=a[0];
for(int i=1;i<=n;i++)
{
if(sum>=a[i])
sum+=a[i];
else
{
int f2=0;
int len1=-1;
if(k>=n-i+1)
{
k=n-i+1;
}
for(int j=2;j<=k;j++)
{
ll cnt=sum;
if(cnt+s[i+j-1]-s[i]<a[i])
continue;
f2=1;
len1=j;
for(int k0=i+j-1;k0>=i;k0--)
{
if(cnt>=a[k0])
cnt+=a[k0];
else
{
f2=0;
break;
}
}
if(f2) break;
}
if(f2)
{
sum+=s[i+len1-1]-s[i-1];
i+=len1-1;
}
else
{
f=0;
break;
}
}
}
if(f) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
A.Link with Bracket Sequence II
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=505;
const ll mod=1e9+7;
ll n,m,a[N];
ll f[N][N];
ll g[N][N];
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--)
{
memset(f,0,sizeof(f));
memset(g,0,sizeof(g));
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=1;i<=n;i++)
{
g[i][i-1]=1; // 空序列算1个
}
for(int len=2;len<=n;len+=2)
{
for(int l=1;l+len-1<=n;l++)
{
int r=l+len-1;
if(a[l]>=0 && a[r]<=0)
{
int e=0;
if(a[l]==0 && a[r]==0)
{
e=m;
}
else if(a[l]==0 || a[r]==0)
{
e=1;
}
else if(a[l]+a[r]==0){
e=1;
}
f[l][r]=g[l+1][r-1]*e%mod;
}
for(int k=l;k<=r-1;k+=2)
{
g[l][r]+=g[l][k-1]*f[k][r]%mod;
g[l][r]%=mod;
}
}
}
cout<<g[1][n]<<endl;
}
return 0;
}
K.Link is as bear
线性基板子
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int n, a[N];
void solve()
{
cin >> n;
for(int i = 0 ; i < n ; i ++ ) cin >> a[i];
int k = 0;
for(int i = 62 ; i >= 0 ; i -- )
{
for(int j = k ; j < n ; j ++ )
{
if(a[j] >> i & 1)
{
swap(a[j], a[k]);
break;
}
}
if(!(a[k] >> i & 1)) continue;
for(int j = 0 ; j < n ; j ++ )
{
if(j != k && (a[j] >> i & 1))
a[j] ^= a[k];
}
k ++ ;
if(k == n) break;
}
int res = 0;
for(int i = 0 ; i < k ; i ++ )
res ^= a[i];
cout << res << endl;
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0);
int T;
cin >> T;
while(T -- ) solve();
return 0;
}