CodeCraft-20 (Div. 2) C. Primitive Primes (数学)

题意:给你两个一元多项式\(f(x)\)和\(g(x)\),保证它们每一项的系数互质,让\(f(x)\)和\(g(x)\)相乘得到\(h(x)\),问\(h(x)\)是否有某一项系数不被\(p\)整除.
题解:这题刚开始看了好久不知道怎么写,但仔细看题目给的条件可能会看出一点门道来,我们知道,\(c_{i}\)是由\(f(x)\)和\(g(x)\)中多个某两项积的和来得到的(\(c_{i}=a_{0}b{i}+a_{1}b_{i-1}+...+a_{i}b_{0}\)),那么我们只要找到第一个不被\(p\)整除的\(a_{i}\)和\(b_{i}\)即可.
代码:
int n,m;
ll p;
ll a[N],b[N]; int main() {
ios::sync_with_stdio(false);cin.tie(0);
cin>>n>>m>>p;
for(int i=0;i<n;++i){
cin>>a[i];
}
for(int i=0;i<m;++i){
cin>>b[i];
}
int pos1=0;
int pos2=0;
for(int i=0;i<n;++i){
if(a[i]%p!=0){
pos1=i;
break;
}
}
for(int i=0;i<m;++i){
if(b[i]%p!=0){
pos2=i;
break;
}
} cout<<pos1+pos2<<endl; return 0;
}
CodeCraft-20 (Div. 2) C. Primitive Primes (数学)的更多相关文章
- Codeforce-CodeCraft-20 (Div. 2)-C. Primitive Primes(本原多项式+数学推导)
It is Professor R's last class of his teaching career. Every time Professor R taught a class, he gav ...
- CF1316C Primitive Primes
CF1316C [Primitive Primes] 给出两个多项式\(a_0+a_1x+a_2x^2+\dots +a_{n-1}x^{n-1}\)和\(b_0+b_1x+b_2x^2+ \dots ...
- S - Primitive Primes CodeForces - 1316C 数学
数学题 在f(x)和g(x)的系数里找到第一个不是p的倍数的数,然后相加就是答案 为什么? 设x1为f(x)中第一个不是p的倍数的系数,x2为g(x)...... x1+x2前的系数为(a[x1+x2 ...
- Primitive Primes - 题解【数学】
题面 It is Professor R's last class of his teaching career. Every time Professor R taught a class, he ...
- Codeforces Round #188 (Div. 2) C. Perfect Pair 数学
B. Strings of Power Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/p ...
- Codeforces Round #376 (Div. 2) F. Video Cards 数学,前缀和
F. Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #337 (Div. 2) C. Harmony Analysis 数学
C. Harmony Analysis The semester is already ending, so Danil made an effort and decided to visit a ...
- Codeforces Round #320 (Div. 2) D. "Or" Game 数学
D. "Or" Game time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #180 (Div. 2) C. Parity Game 数学
C. Parity Game 题目连接: http://www.codeforces.com/contest/298/problem/C Description You are fishing wit ...
随机推荐
- 惠普电脑(HP PHILIPS系列)安装ubuntu后无法连接WIFI解决方案(手动安装8821CE驱动)
一步一步来, 先说环境: 我的电脑是HP PHILIPS系列,ubuntu版本是16.04 背景: win10安装ubuntu后发现无法连接wifi(但win10系统可以连接WIFI),在ubuntu ...
- kaggle新手如何在平台学习大神的代码
原创:数据臭皮匠 [导读]Kaggle ,作为听说它很牛X但从未接触过的同学,可能仅仅了解这是一个参加数据挖掘比赛的网站,殊不知Kaggle也会有赛题相关的数据集, 比如我们熟知的房价预测.泰坦尼克 ...
- 使用Spring的RestTemplate进行接口调用
引自:http://www.zimug.com/ 1.常见的http服务的通信方式 经常使用的方式有HttpClient.OkHttp.RestTemplate.其中RestTemplate是一种更优 ...
- Py装饰器
装饰器: 1.定义,什么是装饰器 装饰器本质是一个函数,它是为了给其他函数添加附加功能 2.装饰器的两个原则 原则1 不修改被修饰函数的源代码原则2 不修改被修饰函数的调用方式 3.首先来看一 ...
- 当中台遇上DDD,我们该如何设计微服务? - InfoQ https://www.infoq.cn/article/7QgXyp4Jh3-5Pk6LydWw
当中台遇上DDD,我们该如何设计微服务? - InfoQ https://www.infoq.cn/article/7QgXyp4Jh3-5Pk6LydWw
- pip freeze 需求文件requirements.txt的创建及使用 虚拟环境
总结: 1.输出安装的包信息,并在另一个环境快速安装 Generate output suitable for a requirements file. $ pip freeze docutils== ...
- 自修改代码 on the fly 动态编译 即时编译 字节码
https://zh.wikipedia.org/wiki/自修改代码 自修改代码(Self-modifying code)是指程序在运行期间(Run time)修改自身指令.可能的用途有:病毒利用此 ...
- httpd反向代理实践(二)
div.example { background-color: rgba(229, 236, 243, 1); color: rgba(0, 0, 0, 1); padding: 0.5em; mar ...
- Canvas实现弧线时钟
最近试着用canvas元素的2d绘图函数做了一个弧线形的时钟. 我也没啥好说的,直接上代码: <div id="myclock"></div> <sc ...
- Kepware软件基本操作及使用Java Utgard实现OPC通信
一.环境搭建(基于win10 64位专业版) 1.Kepware 的下载.安装及使用 https://www.cnblogs.com/ioufev/p/9366877.html 2.重要:OPC 和 ...