牛客小白月赛62 ABC
https://ac.nowcoder.com/acm/contest/47266#question
A-幼稚园的树
输入
2
6
1 10 100 200 120 230
5 230 200
7
5
1 2 3 4 5
10 5 2
1
输出
31 40 130 230 150 225
1 2 3 4 5
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e7+10,M=2023;
const LL mod=1e9+7;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
cin>>T;
while(T--)
{
LL n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
LL aa,k,bb,m;
cin>>aa>>k>>bb>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<m;j++)
{
a[i]+=aa;
if(a[i]>k) a[i]=bb;
}
}
for(int i=1;i<=n;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
return 0;
}
B-剩下的数
输入
1
1 5
2
2
3
输出
1
0
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e7+10,M=2023;
const LL mod=1e9+7;
const double PI=3.1415926535;
#define endl '\n'
LL a[N];
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
cin>>T;
while(T--)
{
LL l,r;
cin>>l>>r;
LL sum=(l+r)*(r-l+1)/2;
LL q;
cin>>q;
while(q--)
{
LL x;
cin>>x;
if(sum%x==0) cout<<"0"<<endl;
else cout<<"1"<<endl;
}
}
return 0;
}
C-数组划分
输入
3
4 1 1
9 7 10
输出
No
示例2
输入
4
1 3 5 7
2 4 8 22
输出
Yes
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=2e7+10,M=2023;
const LL mod=1e9+7;
const double PI=3.1415926535;
#define endl '\n'
LL a[N],b[N];
map<LL,LL> mp;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
LL T=1;
//cin>>T;
while(T--)
{
LL n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
LL x=a[i];
for(int j=2;j*j<=x;j++)
{
while(x%j==0)
{
mp[j]++;
x/=j;
}
}
if(x>1) mp[x]++;
}
bool flag=true;
for(int i=1;i<=n;i++)
{
cin>>b[i];
LL x=b[i];
for(int j=2;j*j<=x;j++)
{
while(x%j==0)
{
if(mp[j]!=0)
{
flag=false;
break;
}
x/=j;
}
}
if(x>1)
{
if(mp[x]!=0)
{
flag=false;
break;
}
}
}
if(flag==true) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}