腾讯软开第三题ac代码
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
bool solution(int A,int B,int C)
{
int t=A%B,res=t;
int n=1;
unordered_map<int,int> M;
while(!M[res])
{
if(res==C)
return true;
M[res]=1;
n;
res=(n*t)%B;
}
return false;
}
int main()
{
int t;
cin>>t;
vector<string> Ans(t,"");
for(int i=0;i<t; i)
{
int A,B,C;
cin>>A>>B>>C;
if(B==1&&C!=0)
Ans[i]="NO";
else
{
if(C==0)
Ans[i]="YES";
else
{
if(solution(A,B,C))
Ans[i]="YES";
else Ans[i]="NO";
}
}
}
for(auto& s:Ans)
cout<<s<<endl;
}
前两题不会嗯,神仙们打架去吧
#算法工程师#