| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 39991 | 氩_wjy | 【S】T2 | C++ | 通过 | 100 | 444 MS | 248 KB | 563 | 2026-02-10 20:30:23 |
#include<bits/stdc++.h> #define int long long using namespace std; int n,q,s; inline int qpow(int a,int b,int mod){ int Ans=1; while(b){ if(b&1)Ans=Ans*a%mod; a=a*a%mod;b>>=1; }return Ans; } inline void slv(){ cin>>n>>s>>q; int Ans=0; for(int i=0;i<n;i++)if((qpow(i,q,n)+i*q)%n==s)(Ans+=i%q)%=q; cout<<Ans<<endl; } signed main(){ #ifndef ONLINE_JUDGE freopen("ticket.in","r",stdin); freopen("ticket.out","w",stdout); #endif int T;cin>>T; while(T--)slv(); return 0; }