日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HNU 11720 God Created The Integers

發布時間:2023/12/13 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HNU 11720 God Created The Integers 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

  原題傳送:http://acm.hnu.cn/online/?action=problem&type=show&id=11720&courseid=0

  對于這條式子:

  

  和下面的式子是等價的:

  Sp = (p2 - 1) / 2 - (p - 1) / 4

  那么求出Sp后有rp*Sp ≡ 1 (mod p),用擴展GCD求出rp就行了。

View Code 1 #include <stdio.h> 2 #include <string.h> 3 4 typedef __int64 LL; 5 LL p, s; 6 7 LL exgcd(LL a, LL b, LL &x, LL &y) 8 { 9 LL d, t; 10 if(b == 0) 11 { 12 x = 1, y = 0; 13 return a; 14 } 15 d = exgcd(b, a % b, x, y); 16 t = x, x = y, y = t - (a / b) * x; 17 return d; 18 } 19 20 void solve(int cas) 21 { 22 s =(p * p - 1) / 24 - (p - 1) / 4; 23 LL x, y; 24 exgcd(s, p, x, y); 25 printf("Case #%d: %I64d\n", cas, (x + p) % p); 26 } 27 28 int main() 29 { 30 int t, cas; 31 while(scanf("%d", &t) != EOF) 32 { 33 for(cas = 1; cas <= t; cas ++) 34 { 35 scanf("%I64d", &p); 36 solve(cas); 37 } 38 } 39 return 0; 40 }

?

  

轉載于:https://www.cnblogs.com/huangfeihome/archive/2012/10/06/2713070.html

總結

以上是生活随笔為你收集整理的HNU 11720 God Created The Integers的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。