Codeforces 595B - Pasha and Phone
代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=1e5+;
const int INF=0x3f3f3f3f;
const int MOD=1e9+;
ll a[N];
int b[N];
int dp[]={};
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,k;
cin>>n>>k;
for(int i=;i<n/k;i++)cin>>a[i];
for(int i=;i<n/k;i++)cin>>b[i];
for(int i=;i<=k;i++)dp[i]=dp[i-]*; ll ans=;
for(int i=;i<n/k;i++)
{
int t=;
ll n1=(dp[k]-)/a[i]+;//a[i]倍数的数量
ll n2=(dp[k-]-)/a[i]+;//最高位为0的a[i]倍数的数量
ll n3=(dp[k-]*(b[i]+)-)/a[i]-(dp[k-]*b[i]-)/a[i];//最高位为b[i]的a[i]的倍数的数量
if(b[i]==)ans*=n1-n2;
else ans*=n1-n3;
ans%=MOD;
}
cout<<ans<<endl;
return ;
}
Codeforces 595B - Pasha and Phone的更多相关文章
- Codeforces 595B. Pasha and Phone 容斥
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- codeforces 557B. Pasha and Tea 解题报告
题目链接:http://codeforces.com/problemset/problem/557/B 题目意思:有 2n 个茶杯,规定第 i 个茶杯最多只能装 ai 毫升的水.现在给出 w 毫升的水 ...
- CodeForces 595B
题目链接: http://codeforces.com/problemset/problem/595/B 题意: 有一个n位的电话号码,每位电话号码将分成n/k段,每段均为k个数,求出满足以下要求的电 ...
- Codeforces 435B. Pasha Maximizes
简单贪心.... B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input s ...
- codeforces B. Pasha and String
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters ...
- codeforces B. Pasha and String(贪心)
题意:给定一个长度为len的字符序列,然后是n个整数,对于每一个整数ai, 将字符序列区间为[ai,len-ai+1]进行反转.求出经过n次反转之后的序列! /* 思路1:将区间为偶数次的直接去掉!对 ...
- [ An Ac a Day ^_^ ] CodeForces 525B Pasha and String 技巧
题意就是一次次翻转字符串 然后输出最终的字符串 暴力一发O(n*m)果然超时了 因为每次翻转的的都是a-1到对称位置 所以一个位置翻转两次等于没有操作 所以只需要记录一下len/2的位置前的操作次数 ...
- CodeForces 610A Pasha and Stick
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using ...
- Codeforces Round #249 (Div. 2)B(贪心法)
B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
随机推荐
- php端口号设置和查看
- [转]Mac Appium环境安装
原文:https://blog.csdn.net/dongqiushan/article/details/53326518 1.安装JDK; 2.安装Android SDK; 3.安装brew; 4. ...
- 错误处理:WebForms UnobtrusiveValidationMode 需要“jquery”ScriptResourceMapping
今天在配置用户权限管理的时候,遇到了这么个错误: WebForms UnobtrusiveValidationMode 需要“jquery”ScriptResourceMapping.请添加一个名为 ...
- SpringBoot之RESTFul风格的接口调用(jQuery-Ajax)
一.Get $.ajax({ type: "get", url: "url地址", async: true, dataType:"json" ...
- Python入门之面向对象的多态
本章目录: 一.多态 二.多态性 三.鸭子类型 ============================== 一.多态 多态指的是一类事物有多种形态. 动物有多种形态:人,狗,猪. import ab ...
- Redis 如何保持和MySQL数据一致【二】
需求起因 在高并发的业务场景下,数据库大多数情况都是用户并发访问最薄弱的环节.所以,就需要使用redis做一个缓冲操作,让请求先访问到redis,而不是直接访问MySQL等数据库. 这个业务场景,主要 ...
- python的time时间模块
模块概述 1.一个.py文件就是一个模块 2.通过import语句在一个模块中导入另一个模块,import sys,print (sys.path),sys.path的结果为一个列表,列表的第一个元素 ...
- dba和运维专家们说有丰富的大型分布式系统架构设计经验纯属扯淡
如果,一开始就从事dba和运维的专家们说他们有丰富的大型分布式系统架构设计经验,那纯属扯淡.除非,他们从是从开发专家或者架构师转型而来,那么他们才有资格说自己有丰富的大型分布式系统架构设计经验. 运维 ...
- jQuery API的特点
jQuery API 的特点 版权声明:未经博主授权,严禁转载分享 jQuery API 的三大特点 1. jQuery 对象是一个类数组对象,API自带遍历效果 - 对 jQuery 对象调用一次A ...
- C#对象的new和不new的区别
new:为对象分配空间. 首先,直接声明一个变量:byte[] test;只是有了一个变量名字,而它是没有实际空间的,需要分配空间: 分配空间的方法: 1.使用new,byte[] test = ne ...