Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:国庆快乐,转发代码 Happy一下In Reply To:国庆快乐,附个代码 Happy一下 Posted by:ACAccepted at 2018-10-06 14:49:58 > #include <cstdio> > using namespace std; > int cas,m,n; > long long a,b,ans; > > long long js(long long a,long long b) > { > if(b==0)return 1; > if(b==1)return a; > long long res=js(a,b/2); > if(b%2==0)return res*res%m; > else return res*res*a%m; > } > > int main() > { > scanf("%d",&cas); > while(cas--) > { > scanf("%d%d",&m,&n); > ans=0; > while(n--) > { > scanf("%I64d%I64d",&a,&b); > a=a%m; > ans=(ans+js(a,b))%m; > } > printf("%I64d\n",ans); > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator