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的更多相关文章

  1. Codeforces 595B. Pasha and Phone 容斥

    B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  2. codeforces 557B. Pasha and Tea 解题报告

    题目链接:http://codeforces.com/problemset/problem/557/B 题目意思:有 2n 个茶杯,规定第 i 个茶杯最多只能装 ai 毫升的水.现在给出 w 毫升的水 ...

  3. CodeForces 595B

    题目链接: http://codeforces.com/problemset/problem/595/B 题意: 有一个n位的电话号码,每位电话号码将分成n/k段,每段均为k个数,求出满足以下要求的电 ...

  4. Codeforces 435B. Pasha Maximizes

    简单贪心.... B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input s ...

  5. codeforces B. Pasha and String

    Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters ...

  6. codeforces B. Pasha and String(贪心)

    题意:给定一个长度为len的字符序列,然后是n个整数,对于每一个整数ai, 将字符序列区间为[ai,len-ai+1]进行反转.求出经过n次反转之后的序列! /* 思路1:将区间为偶数次的直接去掉!对 ...

  7. [ An Ac a Day ^_^ ] CodeForces 525B Pasha and String 技巧

    题意就是一次次翻转字符串 然后输出最终的字符串 暴力一发O(n*m)果然超时了 因为每次翻转的的都是a-1到对称位置 所以一个位置翻转两次等于没有操作 所以只需要记录一下len/2的位置前的操作次数 ...

  8. CodeForces 610A Pasha and Stick

    #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using ...

  9. Codeforces Round #249 (Div. 2)B(贪心法)

    B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

随机推荐

  1. 来自阿里妈妈的iconfont(转)

    转自http://www.augsky.com/775.html 随便说说两者的优缺点 其实主要是说iconfont的优点和Font Awesome的缺点.-_-|||iconfont的图标库相当巨大 ...

  2. Object-C-属性参数

    assign:默认参数setter 方法不会引起引用计数的变化 retain:setter方法首先释放旧的对象,将旧对象的值赋予输入对象,再提高输入对象的引用计数为1 copy:setter 方法首先 ...

  3. POJ3608

    计算两个凸包之间的最小距离,旋转卡壳法详解在旋转卡壳的用法之计算两个凸 包上的最近距离 #include <iostream> #include<cstdio> #includ ...

  4. MySQL从删库到跑路(四)——MySQL数据库创建实例

    作者:天山老妖S 链接:http://blog.51cto.com/9291927 一.创建数据库 1.创建数据库 创建数据库,指定数据库的默认字符集为utf8.create database sch ...

  5. Java(16-19)

    0. 正则表达式: str.matches()  //判断字符串是否匹配 str.split()  // 根据给定正则表达式的匹配规则.拆分此字符串,返回字符串数组. str.replaceAll() ...

  6. Linux基础命令---last

    last 显示以前登录过的用户信息,last指令会搜索/var/log/wtmp文件(或者是经过-f选项指定的文件),然后列出文件中所有的用户信息.如果执行last指令时提示“last /var/lo ...

  7. Xcode10.x适配的部分问题

    因为我们项目是一个Workspace,由若干个库组成(组件化比较碎),又涉及到海外和国内(存在很多差异性),整个项目的编译是由每个库的脚本(每个库生成会支持32位和64位,每次编译前会清除历史缓存), ...

  8. 中国程序化购买广告解析:RTB/DSP/Ad Exchange/SSP/DMP,思维导图

    中国程序化购买广告解析:RTB/DSP/Ad Exchange/SSP/DMP 概念 程序化购买( Programmatic Buying):通过数字化.自动化.系统化的方式改造广告主.代理公司.媒体 ...

  9. Quartz框架调用——运行报错:ThreadPool class not specified

    Quartz框架调用——运行报错:ThreadPool class not specified 问题是在于Quartz框架在加载的时候找不到quartz.properties配置文件: 解决方案一: ...

  10. MQ内存消耗与积压分析

    [root@iZ23nn1p4mjZ logs]# rabbitmqctl status Status of node rabbit@iZ23nn1p4mjZ ... [{pid,15425}, {r ...