B. Turtle Math: Fast Three Task 数学
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int a[N];
void solve(){
int n;
cin>>n;
int sum=0;
map<int,int>mp;
int mx=0;
for(int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
mp[a[i]]=1;
mx=max(mx,a[i]);
}
int cnt1=0;
while(sum%3!=0)sum++,cnt1++;
if(cnt1==1||cnt1==0){
cout<<cnt1<<"\n";
}else{
int f=0;
for(int i=0;(1+3*i)<=mx;i++){
if(mp[1+3*i]){
f=1;
break;
}
}
if(f){
cout<<1<<"\n";
}else{
cout<<2<<"\n";
}
}
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
cin>>t;
for(int i=1;i<=t;i++)solve();
return 0;
}
C. Turtle Fingers: Count the Values of k 暴力
#include<bits/stdc++.h>
#define int long long
using namespace std;
int f(int x,int n){
int res=1;
while(n){
if(n&1){
res=res*x;
}
x*=x;
n>>=1;
}
return res;
}
void solve(){
int a,b,l;
cin>>a>>b>>l;
int x=0,y=0;
while(f(a,x)<=l)x++;
while(f(b,y)<=l)y++;
x--;
y--;
set<int>ans;
for(int i=0;i<=x;i++){
for(int j=0;j<=y;j++){
int k=f(a,i)*f(b,j);
if(l%k==0){
ans.insert(k);
}
}
}
cout<<ans.size()<<"\n";
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
cin>>t;
for(int i=1;i<=t;i++)solve();
return 0;
}
D. Turtle Tenacity: Continual Mods GCD数学
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+10;
int a[N];
void solve(){
int n;cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
int g=a[0];
for(int i=1;i<n;i++) g=__gcd(g,a[i]);
for(int i=0;i<n;i++) a[i]/=g;
sort(a,a+n);
if(a[0]!=a[1]){
cout<<"YES\n";
return;
}
if(a[0]!=1) cout<<"YES\n";
else cout<<"NO\n";
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
cin>>t;
for(int i=1;i<=t;i++)solve();
return 0;
}
标签:int,res,sum,namespace,Codeforces,long,929,cnt1,Div
From: https://www.cnblogs.com/yufan1102/p/18041714