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 ...
随机推荐
- LeetCode-MinimumDepthOfBinaryTree
题目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the ...
- 33. Search in Rotated Sorted Array(二分查找)
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e. ...
- VS2010/MFC编程入门之四十四(MFC常用类:定时器Timer)
前面一节鸡啄米讲了CTime类和CTimeSpan类的使用,本节继续讲与时间有关的定时器.定时器并不是一个类,主要考虑到,提起时间的话就不能不说定时器,所以就把它放到CTime和CTimeSpan之后 ...
- LOJ10067 构造完全图
LOJ10067 构造完全图 最小生成树 每次找到最小的边,将边两端的块合并 (我之前想的是什么鬼) #include<cstdio> #include<algorithm> ...
- 在awk中通过system调用sql语句来说明引号的使用
一个实际应用例子: 在awk中,通过system调用连接数据库并作select操作,select语句中where条件来自于一个文件(file)的第一个域($1). $ cat file ... ... ...
- JAVA I/O(一)基本字节和字符IO流
最近再看I/O这一块,故作为总结记录于此.JDK1.4引入NIO后,原来的I/O方法都基于NIO进行了优化,提高了性能.I/O操作类都在java.io下,大概将近80个,大致可以分为4类: 基于字节操 ...
- __NSCFConstantString && __NSPlaceholderDictionary
一 -[__NSCFConstantString size]: unrecognized selector sent to instance 0x53ea70 该错误是在我将NSString类型的参数 ...
- 在一个activity中销毁指定activity
通过静态变量的方法: 1.在Aactivity中设置一个Activity静态变量 static Activity activity; 2.在onCreate中: activity=this: 3.在B ...
- 格子中输出|2015年蓝桥杯B组题解析第四题-fishers
StringInGrid函数会在一个指定大小的格子中打印指定的字符串. 要求字符串在水平.垂直两个方向上都居中. 如果字符串太长,就截断. 如果不能恰好居中,可以稍稍偏左或者偏上一点. 下面的程序实现 ...
- Max Factor(素数筛法)题解
Max Factor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...