上一页 1 ··· 7 8 9 10 11 12 13 14 15 下一页
摘要: 1 1.gcd(a,b)=gcd(b,a-nb);默认a>=b; 2 设gcd(a,b)=d,gcd(b,a-nb)=k; 3 k|b,k|a-nb;-->k|a 4 即k为a,b的公因数则k|d; 5 又因为d|b,d|a ,所以d|a-nb;所以 d|k-->k=d; 6 又因为当n=q时,a- 阅读全文
posted @ 2021-12-21 22:21 matt-11 阅读(502) 评论(0) 推荐(0)
摘要: 洛谷P1082 [NOIP2012 提高组] 同余方程 这题不能用费马小定理,b不一定是质数,求逆元是能满足互质条件,但是费马小定理还需要b是质数; 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 阅读全文
posted @ 2021-12-21 22:19 matt-11 阅读(51) 评论(0) 推荐(0)
摘要: 洛谷P1082 [NOIP2012 提高组] 同余方程 这题费马小定理肯定不行,费马小定理的前提是p为质数,gcd(a,p)=1,即互质;所以我们只能考虑拓展欧几里得 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long lo 阅读全文
posted @ 2021-12-21 22:13 matt-11 阅读(46) 评论(0) 推荐(0)
该文被密码保护。 阅读全文
posted @ 2021-12-20 21:42 matt-11 阅读(0) 评论(0) 推荐(0)
摘要: P1601 A+B Problem(高精) 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=505; 4 int a[N],b[N],c[N]; 5 void get(string &s,int *p) 6 { 7 int 阅读全文
posted @ 2021-12-19 21:55 matt-11 阅读(81) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 public: 3 long long getDescentPeriods(vector<int>& prices) { 4 int n=prices.size(); 5 long long dp[n+1]; 6 for(int i=1;i<=n;i++)d 阅读全文
posted @ 2021-12-19 14:33 matt-11 阅读(20) 评论(0) 推荐(0)
摘要: 1 class Solution { 2 3 public: 4 int kIncreasing(vector<int>& arr, int k) { 5 int n=arr.size(); 6 int st[n],top=0,ans=0,cnt=0; 7 for(int i=0;i<k;i++) 阅读全文
posted @ 2021-12-19 14:30 matt-11 阅读(115) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int a,b; 4 int gd; 5 vector<int>v; 6 int main() 7 { 8 9 cin>>a>>b; 10 int n; 11 cin>>n; 12 gd=gcd(a 阅读全文
posted @ 2021-12-18 22:26 matt-11 阅读(25) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e6+5; 4 int dp[N];//dp[i]表示以i结尾的最长合法串长度; dp[i]转移,考虑当前i为')' 栈里只压入'('则dp[i]=dp[j-1]+i-j+ 阅读全文
posted @ 2021-12-18 22:20 matt-11 阅读(56) 评论(0) 推荐(0)
摘要: 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=105; 4 int n; 5 int in[N]; 6 vector<int>G[N]; 7 int main() 8 { 9 scanf("%d",&n); 10 que 阅读全文
posted @ 2021-12-18 16:57 matt-11 阅读(62) 评论(0) 推荐(1)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 下一页