C题题目出错了,unrating,2题就能有很好的名次,只能呵呵了。

水 A - Vitaly and Night

/************************************************
* 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;
}

数学 B - Pasha and Phone

题意: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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 随笔—邀请赛前训— Codeforces Round #330 (Div. 2) B题

    题意: 这道英文题的题意稍稍有点复杂. 找长度为n的数字序列有多少种.这个序列可以分为n/k段,每段k个数字.k个数可以变成一个十进制的数Xi.要求对这每n/k个数,剔除Xi可被ai整除的情况,剔除X ...

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

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

  8. 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 ...

  9. 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 ...

随机推荐

  1. 淘宝(阿里百川)手机客户端开发日记第六篇 Service详解(四)

    DEMO1:在Activity里声明一个回调方法,当service完成任务后,调用这个回调方法. 首先,我们先继承service,来创建服务,代码如下: package com.example.ser ...

  2. unity3d的四元数 Quaternion

    原地址:http://www.cnblogs.com/88999660/archive/2013/04/02/2995074.html 今天准备学习和研究下unity3d的四元数 Quaternion ...

  3. hiho一下 第九十六周 数论五·欧拉函数

    题目1 : 数论五·欧拉函数 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho有时候会用密码写信来互相联系,他们用了一个很大的数当做密钥.小Hi和小Ho约定 ...

  4. chrome控制台支持多行js模式

    shift + 回车 是换行 转自: http://zhidao.baidu.com/link?url=MYjGRwvVQYJwnr38VTHPJdzRNtF1COyqpeuAtBYbxFYJcu6p ...

  5. Swap Two Nodes in Linked List

    Given a linked list and two values v1 and v2. Swap the two nodes in the linked list with values v1 a ...

  6. Java for LeetCode 139 Word Break

    Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...

  7. easyfinding(codevs 3280)

    3280 easyfinding  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description 给一个M 行N  列 ...

  8. protostuff简单应用

    protobuf是谷歌推出的与语言无关.平台无关的通信协议,一个对象经过protobuf序列化后将变成二进制格式的数据,所以他可读性差,但换来的是占用空间小,速度快.居网友测试,它的序列化效率是xml ...

  9. Android之自定义控件入门

    本文主要讲述了实现安卓button点击变色与利用ViewPager实现图片自动轮播效果 我伞可以看到在很多应用中,安卓按钮按下时与正常时状态是不同的,这种效果也很容易达到. 第一步:创建XML文件定义 ...

  10. 了解 hadoop

    <Hadoop基础教程>之初识Hadoop 博客分类: 读后感   Hadoop一直是我想学习的技术,正巧最近项目组要做电子商城,我就开始研究Hadoop,虽然最后鉴定Hadoop不适用我 ...