给你一个数组a_i,D(x)为x的约数个数 两种操作: 1.将[l,r]的a_i替换为D(a_i) 2.输出∑a_i ( l <= i <= r ) 当区间最大值<=2时,就不会被修改了,因为d(2)=2,d(1)=1. #include<cstdio> #include<iostream> #define R register int #define ls (tr<<1) #define rs (tr<<1|1) ; using n…
SUM and REPLACE 题意:给你n个数,进行m次操作,分别是将区间[l,r]内的所有数替换成自己的因子数 和 对区间[l,r]进行求和. 题解:可以发现2的因子个数还是2,1的因子个数还是1,所以如果某个数被更新成1或者2之后就不需要再进行更新了. #include<bits/stdc++.h> #define ll long long #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 using namesp…
F. SUM and REPLACE time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) …
Dicription Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) = 4 (6 is divisible by 1, 2, 3 and 6). You are given an array a of n integers. You have to process two types of qu…
题目地址:https://oj.leetcode.com/problems/two-sum/ Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, w…