题解传送门
A Two Regular Polygons
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int x,y;
cin>>x>>y;
if(max(x,y)%min(x,y)==0)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
return 0;
}
B. Bogosort
#include <bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
int t;
cin>>t;
while(t--)
{
int x;
cin>>x;
for(int i=0;i<x;i++)
{
cin>>a[i];
}
sort(a,a+x);
for(int i=x-1;i>=0;i--)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
return 0;
}
C. Adding Powers
#include <bits/stdc++.h>
using namespace std;
long long a[100],b[10000];
int main()
{
int t;
cin>>t;
while(t--)
{
long long n,k,flag=0;
cin>>n>>k;
int ax=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
memset(b,0,sizeof(b));
for(int i=0;i<n;i++)
{
ax=0;
while(a[i])
{
b[ax]+=a[i]%k;
if(b[ax]>1)
{
flag=1;
}
a[i]=a[i]/k;
ax++;
}
}
if(flag==0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
D. Count the Arrays
直接复制别人的代码的真的,写的比我好的多,orz
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int inf=0x3f3f3f3f;
const int N=110;
const int mod=998244353;
LL q_pow(LL a,LL b)
{
if(b<0)
return 0;
LL ans=1;
while(b)
{
if(b&1)
ans=ans*a%mod;
a=a*a%mod;
b>>=1;
}
return ans;
}
LL C(int n,int m)
{
LL ans1=1;//分子
LL ans2=1;//分母
for(int i=0;i<m;i++)
{
ans1=ans1*(n-i)%mod;
ans2=ans2*(i+1)%mod;
}
ans2=q_pow(ans2,mod-2);
return ans1*ans2%mod;
}
//C(m,n-1)*(n-2)*pow(2,n-3);
int main()
{
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
// ios::sync_with_stdio(false);
int n,m;
scanf("%d%d",&n,&m);
printf("%lld\n",C(m,n-1)*(n-2)%mod*q_pow(2,n-3)%mod);
return 0;
}