A/B Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2017    Accepted Submission(s): 1469 Problem Description 要求(A/B)%9973,但因为A非常大,我们仅仅给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1).   Input 数据的第一…
http://acm.hdu.edu.cn/showproblem.php?pid=1576 A/B Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3351 Accepted Submission(s): 2545 Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必…
题目链接:pid=2669">http://acm.hdu.edu.cn/showproblem.php?pid=2669 Problem Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Trees Trees are Shaking, Leaves are Falling. Lovers Walk passing, and so are Yo…
裸的扩展欧几里德,求最小的X,X=((X0%b)+b)%b,每个X都对应一个Y,代入原式求解可得 #include<stdio.h> #include<string.h> typedef long long ll; ll ex_gcd(ll a,ll b,ll &x,ll &y){ if(!b){ x=,y=; return a; } int ans=ex_gcd(b,a%b,y,x); y-=a/b*x; return ans; } void cal(ll a,l…
设A/B=x,则A=Bx n=A%9973=A-9973*y=Bx-9973*y 用扩展欧几里德求解 #include<stdio.h> #include<string.h> typedef long long ll; ll ex_gcd(ll a,ll b,ll &x,ll &y){ if(!b){ x=,y=; return a; } ll ans=ex_gcd(b,a%b,y,x); y-=a/b*x; return ans; } void cal(ll a,…
Romantic Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2385    Accepted Submission(s): 944 Problem Description The Sky is Sprite.The Birds is Fly in the Sky.The Wind is Wonderful.Blew Throw th…
题目 //第一眼看题目觉得好熟悉,但是还是没想起来//洪湖来写不出来去看了解题报告,发现是裸的 扩展欧几里得 - - /* //扩展欧几里得算法(求 ax+by=gcd )//返回d=gcd(a,b);和对应于等式ax+by=d中的x,y#define LL long longLL extend_gcd(LL a,LL b,LL &x,LL &y){ if(a==0&&b==0) return -1;//无最大公约数 if(b==0){x=1;y=0;return a;}…
Invoker Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 122768/62768K (Java/Other) Total Submission(s) : 1   Accepted Submission(s) : 0 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description On of Vance's favourite hero i…
模板: int Extend_Euclid(int a, int b, int &x, int &y){         if(b == 0){             x = 1; y = 0;             return a;         }         else{             int gcd,t;             gcd = Extend_Euclid(b, a%b, x, y);             t = x;             x…
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1576 分析:等式枚举法,由题意可得:, ,代入 ,    得:,把变量 合在一起得: :即满足 为 倍数,因为 ,所以解时唯一的. 使用扩展欧几里德算法 或 费马小定理 来求解,涉及到有关逆元的知识这里就不详细叙述了. 代码如下:        方法一(等式枚举): #include <bits/stdc++.h> using namespace std; int main(void) { int…