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 ...
随机推荐
- 卷积神经网络学习笔记——SENet
完整代码及其数据,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/DeepLearningNote 这里结合网络的资料和SE ...
- 用APICloud开发iOS App Clip详细教程
App Clip是苹果公司在WWDC20开发者大会上发布的新功能,用户可以只访问应用程序的一小部分,而无需下载整个应用,被称为苹果小程序.本文主要介绍如何通过APICloud开发App Clip. 一 ...
- ichartjs测试dome分享
效果如下: 代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> ...
- 微信小程序腾讯地图SDK使用方法
一.本篇文章主要知识点有以下几种: 1.授权当前位置 2.map组件的使用 3.腾讯地图逆地址解析 4.坐标系的转化 二.效果如下: 三.WXML代码 <map id="map&quo ...
- Android iText向pdf模板插入数据和图片
一.需求 这些日志在写App程序,有这么一个需求,就是需要生成格式统一的一个pdf文件,并向固定表格中填充数据,并且再在pdf中追加两页图片. 二.方案 手工设计一个pdf模板,这个具体步骤就不再赘述 ...
- Python小度
这只是一个对话器!还不能听歌(反正我也没在UNIT平台配置听歌的功能)! 反正最近也不知怎么的,就想做一个AI对话器语音识别和语音输出都不要,input()和print()就行本来准备用小爱的,但要实 ...
- Linux安装Oracle数据库SQLPlus客户端
安装 RPM包下载地址:https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html ...
- mybatis源码解析之架构理解
mybatis是一个非常优秀的开源orm框架,在大型的互联网公司,基本上都会用到,而像程序员的圣地-阿里虽然用的是自己开发的一套框架,但其核心思想也无外乎这些,因此,去一些大型互联网公司面试的时候,总 ...
- class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
class CacheMiddleware(UpdateCacheMiddleware, FetchFromCacheMiddleware):
- What is the difference between btree and rtree indexing?
https://softwareengineering.stackexchange.com/questions/113256/what-is-the-difference-between-btree- ...