Powered by:AB_IN 局外人
A 遗忘的泰勒
t=int(input())
while t>0:
t-=1
n=int(input())
if n&1:
print("YES")
else:
print("NO")
B 多余的字母
t=int(input())
while t>0:
t-=1
s=input().strip()
for i in s:
if i.islower():
print(i,end="")
print()
C 种花
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
typedef unsigned long long ll;
const ll maxn=1e6;
using namespace std;
namespace IO{
char ibuf[1<<21],*ip=ibuf,*ip_=ibuf;
char obuf[1<<21],*op=obuf,*op_=obuf+(1<<21);
inline char gc(){
if(ip!=ip_)return *ip++;
ip=ibuf;ip_=ip+fread(ibuf,1,1<<21,stdin);
return ip==ip_?EOF:*ip++;
}
inline void pc(char c){
if(op==op_)fwrite(obuf,1,1<<21,stdout),op=obuf;
*op++=c;
}
inline int read(){
register int x=0,ch=gc(),w=1;
for(;ch<'0'||ch>'9';ch=gc())if(ch=='-')w=-1;
for(;ch>='0'&&ch<='9';ch=gc())x=x*10+ch-48;
return w*x;
}
template<class I>
inline void write(I x){
if(x<0)pc('-'),x=-x;
if(x>9)write(x/10);pc(x%10+'0');
}
class flusher_{
public:
~flusher_(){if(op!=obuf)fwrite(obuf,1,op-obuf,stdout);}
}IO_flusher;
}
ll x,y,t,nx,ny;
int main()
{
using namespace IO;
t=read();
while(t--){
ll ans=0;
x=read();y=read();
if(x==y){
write(x*4);pc('\n');
continue;
}
else{
while(1){
nx=min(x,y);
ny=max(x,y);
if(nx==1)
{ans+=ny*4;break;}
ny-=nx;
ans+=nx*4;
x=nx;
y=ny;
if(nx==ny)
{ans+=nx*4;break;}
}
}
write(ans);pc('\n');
}
}
D 最大的收益
DP
dp[i][1]
代表这次我选这个数,那么总数就是这个数和上个不选这个数的值相加。dp[i][0]
代表这次我不选这个数,那么这个值就是上一个状态两个值中的最大值。
#include <bits/stdc++.h>
typedef long long ll;
const ll maxn=1e4;
using namespace std;
namespace IO{
char ibuf[1<<21],*ip=ibuf,*ip_=ibuf;
char obuf[1<<21],*op=obuf,*op_=obuf+(1<<21);
inline char gc(){
if(ip!=ip_)return *ip++;
ip=ibuf;ip_=ip+fread(ibuf,1,1<<21,stdin);
return ip==ip_?EOF:*ip++;
}
inline void pc(char c){
if(op==op_)fwrite(obuf,1,1<<21,stdout),op=obuf;
*op++=c;
}
inline int read(){
register int x=0,ch=gc(),w=1;
for(;ch<'0'||ch>'9';ch=gc())if(ch=='-')w=-1;
for(;ch>='0'&&ch<='9';ch=gc())x=x*10+ch-48;
return w*x;
}
template<class I>
inline void write(I x){
if(x<0)pc('-'),x=-x;
if(x>9)write(x/10);pc(x%10+'0');
}
class flusher_{
public:
~flusher_(){if(op!=obuf)fwrite(obuf,1,op-obuf,stdout);}
}IO_flusher;
}
ll a[maxn],dp[maxn][2],t,n;
int main()
{
using namespace IO;
t=read();
while(t--)
{
n=read();
for(int i=1;i<=n;i++)
a[i]=read();
dp[1][0]=0;
dp[1][1]=a[1];
for(int i=2;i<=n;i++)
{
dp[i][1]=dp[i-1][0]+a[i];
dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
}
write(max(dp[n][0],dp[n][1]));
pc('\n');
}
}
完结。