题意:

这道英文题的题意稍稍有点复杂。

找长度为n的数字序列有多少种。这个序列可以分为n/k段,每段k个数字。k个数可以变成一个十进制的数Xi。要求对这每n/k个数,剔除Xi可被ai整除的情况,剔除X的第一个数(包括前导0)是bi的情况。问剩下的组合有多少种。

思路:

这题我是一波三折的。首先也没有考虑很多,看着可以暴力模拟过程,我就直接开始敲了,几个for循环敲出来,再把bug调一调和特殊情况考虑考虑,交了之后开始TLE,这时候意识到复杂度太大了,于是开始优化,做了(b[i])*(mmax/10)-1    ~     (b[i]+1)*(mmax/10)-1    的循环范围优化后,后面的案例又超时了,后来觉得应该不能暴力模拟了,注意到一定范围内可以被一个数整除的数的数目是可以通过公式算的,这才用公式直接计算省去了for循环,这才过了题。

#include<cstdio>
#include<cstring>
#include<iostream> using namespace std; #define MAX(x,y) (((x)>(y)) ? (x) : (y))
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define ABS(x) ((x)>0?(x):-(x)) const int inf = 0x7fffffff;
const int N=+;
const long long mod=1e9+; int a[N];
int b[N]; int main()
{
// freopen("out.txt", "w", stdout);
int n;
int k;
cin>>n>>k;
int kk=k;
long long mmax=; while(kk--)
mmax *= ;
// cout<<mmax; int num=n/k;
for(int i=; i<num; i++)
scanf("%d",a+i);
for(int i=; i<num; i++)
scanf("%d",b+i); long long ans=; for(int i=; i<num; i++)
{
long long cnt=(mmax-)/a[i]+;
if(b[i] == ){
cnt-=(mmax/-)/a[i]+; }
else{
cnt=cnt-( ((b[i]+)*(mmax/)-)/a[i]+ ) + ( ((b[i])*(mmax/)-)/a[i]+ ); }
ans=ans*cnt % mod;
}
cout<<ans<<endl;
return ;
}

随笔—邀请赛前训— Codeforces Round #330 (Div. 2) B题的更多相关文章

  1. 随笔—邀请赛前训— Codeforces Round #330 (Div. 2) Vitaly and Night

    题意:给你很多对数,要么是0要么是1.不全0则ans++. 思路即题意. #include<cstdio> #include<cstring> #include<iost ...

  2. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  3. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  4. Codeforces Round #552 (Div. 3) A题

    题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...

  5. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  6. Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring

    D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  7. Codeforces Round #330 (Div. 1) A. Warrior and Archer 贪心 数学

    A. Warrior and Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594 ...

  8. Codeforces Round #330 (Div. 1) C. Edo and Magnets 暴力

    C. Edo and Magnets Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594/pr ...

  9. Codeforces Round #330 (Div. 2)D. Max and Bike 二分 物理

    D. Max and Bike Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/probl ...

随机推荐

  1. C语言数组初始化

    例如: int a[15] = {0}; 第一种,编译器会把第一个初始化值赋给数组的第一个元素,然后用0赋给其余的元素.如果没有给出初始值,编译器不会去做初始化工作.这样简洁的方式让代码更加高效. 还 ...

  2. Linux分区介绍

    分区的大小主要取决于个人的选择,以下内容可能会有一定帮助:/boot - 200 MB 实际需求大约 100 MB,如果有多个内核/启动镜像同时存在,建议分配 200 或者 300 MB./ - 15 ...

  3. ES TIPS

    1,Testing Analyzers Especially when you are new to Elasticsearch, it is sometimes difficult to under ...

  4. Nginx-ngx_lua模块原理和内置函数

    ngx_lua模块的原理: 1.每个worker(工作进程)创建一个Lua VM,worker内所有协程共享VM:2.将Nginx I/O原语封装后注入 Lua VM,允许Lua代码直接访问:3.每个 ...

  5. There is already an open DataReader associated with this Command which must be closed first." exception in Entity Framework

    Fixing the "There is already an open DataReader associated with this Command which must be clos ...

  6. 士兵站队问题sol

    作者:http://www.cnblogs.com/taoziwel/articles/1859577.html 相类似题目:输油管道问题 [问题描述] 在一个划分成网格的操场上,n个士兵散乱地站在网 ...

  7. Spring4.1.6 标签注解大全以及解释

    常用的spring注解有如下几种: @Controller@Service@Autowired@RequestMapping@RequestParam@ModelAttribute@Cacheable ...

  8. mac android studio 编译时报Class JavaLaunchHelper is implemented in both

    Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Cont ...

  9. HTML 事件属性_03

    全局事件属性 HTML 4 的新特性之一是可以使 HTML 事件触发浏览器中的行为,比方说当用户点击某个 HTML 元素时启动一段 JavaScript. 如果你想学习更多关于事件属性,请访问 Jav ...

  10. 虚拟机Ubuntu16,caffe环境搭建

    虚拟机下的Ubuntu16.04+caffe+onlycup 官网的step很重要,要跟着官网,的步骤来:http://caffe.berkeleyvision.org/installation.ht ...