不会
题意:给出了两个多项式的系数,求两个多项式相乘后问系数不能被 p 整除的幂的值。
思路:ci=a∗bi+a1∗bi−1+…+ai−1∗b1+ai∗b0。
倘若
如果在把两个多项式乘开之后,满足c%p!=0,则一定有一个和c相同x幂的系数(a*b)%p != 0,但是如果还有其他相同x幂的系数爷满足不整除0,则结果c不一定为整除p。
如果取a,b分别为a数组和b最先不能整除p的数,因为和(a*b)具有相同x幂的系数是有(a前面的数*b后面的数)或者(b前面的数*a后面的数),因为a,b前面都没有不能整除p的数。所以除了a*b满足不能整除p,其余的都能整除p,所以c%p != 0。
#include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <string> #include <map> #include <iomanip> #include <algorithm> #include <queue> #include <stack> #include <set> #include <vector> // #include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define sp ' ' #define endl '\n' #define inf 0x3f3f3f3f; #define FOR(i,a,b) for( int i = a;i <= b;++i) #define bug cout<<"--------------"<<endl #define P pair<int, int> #define fi first #define se second #define pb(x) push_back(x) #define ppb() pop_back() #define mp(a,b) make_pair(a,b) #define ms(v,x) memset(v,x,sizeof(v)) #define rep(i,a,b) for(int i=a;i<=b;i++) #define repd(i,a,b) for(int i=a;i>=b;i--) #define sca3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c)) #define sca2(a,b) scanf("%d %d",&(a),&(b)) #define sca(a) scanf("%d",&(a)); #define sca3ll(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c)) #define sca2ll(a,b) scanf("%lld %lld",&(a),&(b)) #define scall(a) scanf("%lld",&(a)); using namespace std; typedef long long ll; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll powmod(ll a, ll b, ll mod){ll sum = 1;while (b) {if (b & 1) {sum = (sum * a) % mod;b--;}b /= 2;a = a * a % mod;}return sum;} const double Pi = acos(-1.0); const double epsilon = Pi/180.0; const int maxn = 1e6+10; ll n,m,p; inline ll read() { ll hcy = 0, dia = 1;char boluo = getchar(); while (!isdigit(boluo)) {if (boluo == '-')dia = -1;boluo = getchar();} while (isdigit(boluo)) {hcy = hcy * 10 + boluo - '0';boluo = getchar();} return hcy * dia; } ll a[maxn]; ll b[maxn]; int main() { n = read(); m = read(); p = read(); rep(i,0,n-1) { a[i] = read(); a[i] %= p; } rep(i,0,m-1) { b[i] = read(); b[i] %= p; } ll pos1 =0,pos2 = 0; rep(i,0,n-1){ if(a[i] != 0) { pos1 = i; break; } } rep(i,0,m-1){ if(b[i] != 0) { pos2 = i; break; } } printf("%lld\n",pos1+pos2 ); }