Codeforces Round #330 (Div. 2)
C题题目出错了,unrating,2题就能有很好的名次,只能呵呵了。
/************************************************
* Author :Running_Time
* Created Time :2015/11/8 星期日 22:41:11
* File Name :A.cpp
************************************************/ #include <bits/stdc++.h>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos (-1.0);
int a[110][220]; int main(void) {
int n, m; cin >> n >> m;
for (int i=1; i<=n; ++i) {
for (int j=1; j<=2*m; ++j) cin >> a[i][j];
}
int ans = 0;
for (int i=1; i<=n; ++i) {
for (int j=1; j<=2*m-1; j+=2) {
if (a[i][j] == 1 || a[i][j+1] == 1) ans++;
}
}
cout << ans; //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0;
}
题意:n个数字分成n/k块,每块有k个数字,问n个数字,其中每一块第一个数字不是b[i]且该k个数字组成的数字能整除a[i]的方案数
分析:直接说方法吧,最大的数字比如999999除以a[i]就是所有在99999范围内a[i]的倍数,然后减去以b[i]开头的那些数字就是一块的方案数。我脑子没转过弯,用乘法一个一个乘,当然超时,怎么没想到除呢,还想用DP? (a[i] < 10 ^ k),(卒
/************************************************
* Author :Running_Time
* Created Time :2015/11/8 星期日 22:41:14
* File Name :B.cpp
************************************************/ #include <bits/stdc++.h>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos (-1.0);
ll a[N], b[N]; ll get_max(int k) {
ll ret = 0;
for (int i=1; i<=k; ++i) {
ret = ret * 10 + 9;
}
return ret;
} ll get_b_max(ll x, int k) {
ll ret = x;
for (int i=1; i<k; ++i) {
ret = ret * 10 + 9;
}
return ret;
} ll get_b_min(ll x, int k) {
ll ret = x;
for (int i=1; i<k; ++i) {
ret = ret * 10;
}
return ret;
} ll multi_mod(ll a, ll b) {
ll ret = 0;
while (b) {
if (b & 1) {
ret += a;
if (ret >= MOD) ret -= MOD;
}
b >>= 1; a <<= 1;
if (a >= MOD) a -= MOD;
}
return ret;
} int main(void) {
int n, k; cin >> n >> k;
int m = n / k;
for (int i=1; i<=m; ++i) {
cin >> a[i];
}
for (int i=1; i<=m; ++i) {
cin >> b[i];
}
ll ans = 1, mx = get_max (k);
for (int i=1; i<=m; ++i) {
ll cnt = mx / a[i] + 1;
ll bmn = get_b_min (b[i], k), bmx = get_b_max (b[i], k);
cnt -= (bmx / a[i] - bmn / a[i]);
if (bmn % a[i] == 0) cnt--;
ans = multi_mod (ans, cnt);
}
cout << ans << endl; //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0;
}
Codeforces Round #330 (Div. 2)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #330 (Div. 2) B. Pasha and Phone 容斥定理
B. Pasha and Phone Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/pr ...
- Codeforces Round #330 (Div. 2) A. Vitaly and Night 暴力
A. Vitaly and Night Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/p ...
- 随笔—邀请赛前训— Codeforces Round #330 (Div. 2) B题
题意: 这道英文题的题意稍稍有点复杂. 找长度为n的数字序列有多少种.这个序列可以分为n/k段,每段k个数字.k个数可以变成一个十进制的数Xi.要求对这每n/k个数,剔除Xi可被ai整除的情况,剔除X ...
- 随笔—邀请赛前训— Codeforces Round #330 (Div. 2) Vitaly and Night
题意:给你很多对数,要么是0要么是1.不全0则ans++. 思路即题意. #include<cstdio> #include<cstring> #include<iost ...
- Codeforces Round #330 (Div. 2) B. Pasha and Phone
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #330 (Div. 2) B 容斥原理
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard i ...
随机推荐
- SpringMVC关于json、xml自动转换的原理研究
SpringMVC是目前主流的Web MVC框架之一. 如果有同学对它不熟悉,那么请参考它的入门blog:http://www.cnblogs.com/fangjian0423/p/springMVC ...
- 【风雪之隅】写在PHP7发布之际一些话 2015-12-02
做开源也有4,5年的时间了,从最初的 Yaf,到今天的 PHP7,我参与的项目越来越多,使用我代码的用户也越来越多,明天就要发布的PHP7,绝对是我从事开源以来的一个最重要里程碑,我应该纪念一下今天, ...
- Sed替换行和字符shell
1.在某一行后面追加一行 RD=2000sed -i '/ssi_types/ a\limit_req zone=lreq burst='$RD';' /opt/bee.location 2.替换字符 ...
- 淘宝(阿里百川)手机客户端开发日记第九篇 Looper详解
public final class Looper: 官方的API: Class used to run a message loop for a thread. Threads by default ...
- MySQL数据库服务器的架设
导读 MySQL数据库是Linux操作系统上用得最多的数据库系统,它可以非常方便的与其它服务器集成在一起,如Apache.Vsftpd.Postfix等.下面介绍RHEL 6平台MySQL数据库服务器 ...
- BNUOJ 1037 精神控制
XsuagrX喜欢到处唬人,各种唬.这不,经过刻苦修炼,他终于掌握了Bane Element的Ultra绝技加强版,恶魔掌控(快捷键F)(YY中&……).当XsugarX对某个人胡言乱语Q@# ...
- microsoft office安装选择
office分为零售版和批量授权版 零售版(文件名以cn开头)需要提供序列号才可以安装,而批量授权版(文件名以SW开头)可以先安装试用一段时间.
- Android mtk单路录音问题
在单路录音中,有两种情况导致底层录音资源被占用的问题: 1 开启vmLog后,拨打一个电话,挂断电话.如果挂断电话后,没有关闭vmlog进程,则会导致其它AP 无法得到底层的录音资源,从而无法录音. ...
- annotation(@Retention@Target)详解
一.注解:深入理解JAVA注解 要深入学习注解,我们就必须能定义自己的注解,并使用注解,在定义自己的注解之前,我们就必须要了解Java为我们提供的元注解和相关定义注解的语法. 1.元注解(meta-a ...
- spring中注解的通俗解释
我们在没有用注解写spring配置文件的时候,会在spring配置文件中定义Dao层的bean,这样我们在service层中,写setDao方法,就可以直接通过接口调用Dao层,用了注解写法后,在配置 ...