Home  >  Article  >  Database  >  Codeforces Round #232 (Div. 2)

Codeforces Round #232 (Div. 2)

WBOY
WBOYOriginal
2016-06-07 15:44:23895browse

Problems # Name A On Segment's Own Points standard input/output 1 s, 256 MB x1657 B On Corruption and Numbers standard input/output 1 s, 256 MB x925 C On Number of Decompositions into Multipliers standard input/output 1 s, 256 MB x181 D On

Problems

Codeforces Round #232 (Div. 2)

 

 

# Name    
A

On Segment's Own Points

standard input/output

1 s, 256 MB
Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) x1657
B

On Corruption and Numbers

standard input/output

1 s, 256 MB
Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) x925
C

On Number of Decompositions into Multipliers

standard input/output

1 s, 256 MB
Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) x181
D

On Sum of Fractions

standard input/output

2 s, 256 MB
Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) x134
E

On Changing Tree

standard input/output

2 s, 256 MB
Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) Codeforces Round #232 (Div. 2) x34


A题:n个区间,你可以选择第一个区间上的位置,后面n-1行是被占掉的区间,求你最多能占多长的区间。

思路:n才100,直接暴力,把出现过的区间标记掉,最后去遍历一遍即可。

B题:你有l-r的硬币,要组合出x的钱,问能否组合。

思路:可以的区间为1*[l,r], 2 * [l,r], 3 * [l,r]....直到后面区间重合了之后都是一直可以的,所以用x / l求出i。然后乘上r判断n在不在区间内即可。

C题:m是a1*a2*a3..*an。问m有几种分解成n个数相乘的不同方法。

思路:先分解所有a的分解成质因子,然后等同于把质因子放入n个位置去,用隔板法,每个质因子的方法为C(n - 1 + k) (n - 1)种,k为该质因子个数。

D题:求出题目给定公式值。

思路:先推公式1/u(i) * 1/v(i) = 1/(v(i) - u(i)) * (1/v(i) - 1/u(i))。如此一来前面每一项等于(1/2 - 1/3) + (1/3 - 1/5) + (1/5 - 1/7).....(1/m - 1/n) = 1/2 - 1/n。然后关键就变成找出n的上下质数,这步用暴力枚举,直到是质数为止。然后求出总和即可。

E题:n个点的有根树,根为1,操作1在v结点添加,距离为i的子节点添加值为x - i * k。2为询问。

思路:树状数组,在添加的时候,先假设是从根添加,这样要多添加k * dep[v]。然后开2个树状数组一个记录sum和一个记录k。这样一来最后答案变为

sum - k * dep[v];

代码:

A:

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int N = 105;
int n, i, vis[N], l, r, ll, rr;

int main() {
    scanf("%d", &n);
    scanf("%d%d", &ll, &rr);
    for (i = 2; i <br>
B:
<pre class="brush:php;toolbar:false">#include <stdio.h>
#include <string.h>

int t;
__int64 n, l, r, i;

bool solve() {
    if (n <br>
C:
<pre class="brush:php;toolbar:false">#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
using namespace std;

const int MOD = 1000000007;
const int N = 505;
const int MAXN = 20005;
int n, a, cnt = 0, num[MAXN], c[20005][1005];
map<int> v;

void getnum(int x) {
	for (int i = 2; i * i <br>
D:
<pre class="brush:php;toolbar:false">#include <stdio.h>
#include <string.h>

const int MAXN = 100005;
int t;
__int64 n, l, r, prime[MAXN], vis[MAXN], pn = 0;

void init() {
	for (int i = 2; i <br>
E:
<pre class="brush:php;toolbar:false">#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
const int N = 300005;
const int MOD = 1000000007;
int n, Q, i, nod, vis[N];
__int64 kbit[N], sbit[N], cnt = 0, l[N], r[N], dep[N];
vector<int> g[N];
void dfs(int u, __int64 d) {
    vis[u] = 1; dep[u] = d;
    cnt++; l[u] = cnt;
    for (int i = 0; i  0) {
        ans = (ans + num[x]) % MOD;
        x -= (x&(-x));
    }
    return ans;
}

int main() {
    scanf("%d", &n);
    for (i = 2; i <br>
<br>

<p><br>
</p>


</int></vector></string.h></stdio.h>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:【图论】2Next article:Topcoder srm 653 div.2 500