标签:技术 content bottom panel 技术分享 open sed mis src
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6677 Accepted Submission(s): 5295
#include<cstdio> #include<cstring> #define ll long long const int mod=9973; ll inv(ll a,ll b) { ll ans=1; while(b) { if(b&1) ans=ans*a%mod; b>>=1; a=a*a%mod; } return ans; } int main() { int t; scanf("%d",&t); while(t--) { ll n,b; scanf("%lld %lld",&n,&b); // printf("%d",mod); printf("%lld\n",(n*inv(b,mod-2))%mod); } return 0; }
求逆元;
求(n*inv(b,mod-2))%mod;
注意用long long ;(我老是忘记!!)
下面是一道水题:gcd&&lcm
#include<cstdio> #include<cstring> int gcd(int a,int b) { if(!b) return a; return gcd(b,a%b); } int main() { int t; scanf("%d",&t); while(t--) { int a,b,c,d; scanf("%d %d %d %d",&a,&b,&c,&d); //printf("%d\n",xx); int tlcm=b*d/gcd(b,d); int tup=a*(tlcm/b)+c*(tlcm/d); int tt=gcd(tlcm,tup); printf("%d %d\n",tup/tt,tlcm/tt); } return 0; }
无聊写写;
标签:技术 content bottom panel 技术分享 open sed mis src
原文地址:http://www.cnblogs.com/12fs/p/7581418.html