ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

codeforces 1316 C math

2020-07-02 10:01:35  阅读:270  来源: 互联网

标签:1316 lld ll codeforces boluo include 整除 math define


不会

题意:给出了两个多项式的系数,求两个多项式相乘后问系数不能被 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 );

}

 

标签:1316,lld,ll,codeforces,boluo,include,整除,math,define
来源: https://www.cnblogs.com/jrfr/p/13223094.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有