Powered by:AB_IN 局外人
第一場
光簽到了,還沒來得及補題,沒想到130分還能73。。。
A 牛牛的密碼
純模拟
s=input()
l1=[]
l2=[]
l3=[]
l4=[]
ans=0
for i in s:
if 'a'<=i<='z':
l1.append(i)
elif 'A'<=i<='Z':
l2.append(i)
elif '0'<=i<='9':
l3.append(i)
else:
l4.append(i)
if l1:
ans+=1
if l2:
ans+=1
if l3:
ans+=1
if l4:
ans+=1
print(f"password level:{ans}")
if l1:
print("".join(l1))
else:
print("(Null)")
if l2:
print("".join(l2))
else:
print("(Null)")
if l3:
print("".join(l3))
else:
print("(Null)")
if l4:
print("".join(l4))
else:
print("(Null)")
第二場
因為失誤扔了70分,我是廢物。
A 面試
純模拟
for _ in range(int(input())):
s=input()
if s.count("D")>=1 or s.count("C")>=2:
print("failed")
elif s.count("A")>=3 and "D" not in s:
print("sp offer")
else:
print("offer")
B 紙牌遊戲
這個題一時沖動用 w h i l e while while寫的,結果寫了個死循環。。
思維題,先給數組升序,讓他們有單調的性質,友善後面處理。從第一個人開始,他可以拿 a [ i ] a[i] a[i]個牌,後面的每一個人都可以從第一個人這裡拿 1 1 1張牌,是以顯而易見,我們需要比較兩個值的大小 a [ i ] a[i] a[i]和 n − i − 1 n-i-1 n−i−1(他左邊的人數)
- 如果 a [ i ] < n − i − 1 a[i] \lt n-i-1 a[i]<n−i−1 ,說明這個人終究會被淘汰,拿的牌比被拿的牌少。
- 如果 a [ i ] ≥ n − i − 1 a[i] \ge n-i-1 a[i]≥n−i−1 ,說明這個人不會被淘汰,那麼他後頭的人更不會被淘汰,是以直接輸出連帶這個人和後面人的數量即可。
n=int(input())
lst=list(map(int,input().split()))
lst.sort()
for i in range(n):
if lst[i]>=n-i-1:
print(n-i)
break
C 紙牌遊戲
- m < 2 m < 2 m<2時,這時的 C C C的還沒被淘汰,是以還得加上
- m > = 2 m>=2 m>=2時,這時 C C C的已經被淘汰了,是以降序排序後,就一直取前 x + y x+y x+y的數即可,快速幂寫一下就行了。
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define db double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define rep1(i, a, n) for (int i = a; i < n; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define per1(i ,a, n) for (int i = a; i > n; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
const int inf=0x3f3f3f3f;
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 ll read(){
ll 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;
}
using namespace IO;
ll qm (ll a, ll b ,ll c){
ll ret=1%c;
while(b){
if(b&1)
ret=ret*a%c;
a=a*a%c;
b=b>>1;
}
return ret;
}
const int N=1e6+10;
const int mod=1e9+7;
ll n,m,x,y,a[N],ans1,ans2,ans;
int main()
{
n=read();m=read();x=read();y=read();
rep(i, 1, n) {
a[i]=read();
}
sort(a+1,a+1+n,greater<ll>());
rep(i, 1, n){
if(i<=x) ans1=(ans1+a[i])%mod;
if(i>x && i<=x+y) ans2=(ans2+a[i])%mod;
}
if(m < 2){
rep(i, x+y+1, n){
ans=(ans+a[i])%mod;
}
}
write((ans%mod+ans1*qm(3,m,mod)%mod+ans2*qm(2,m,mod)%mod)%mod);
return 0;
}
完結。