链接: https://vjudge.net/problem/LightOJ-1369 题意: The problem you need to solve here is pretty simple. You are give a function f(A, n), where A is an array of integers and n is the number of elements in the array. f(A, n) is defined as follows: long lo…
题目链接:https://vjudge.net/contest/28079#problem/P 题目大意:给你数组A[]以及如下所示的函数f: long long f( int A[], int n ) { // n = size of A long long sum = 0; for( int i = 0; i < n; i++ ) for( int j = i + 1; j < n; j++ ) sum += A[i] - A[j]; return sum; } 有两个操作:0  x  v…
1369 - Answering Queries   PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 MB The problem you need to solve here is pretty simple. You are give a function f(A, n), where A is an array of integers and n is the number of element…
1369 - Answering Queries    PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 MB The problem you need to solve here is pretty simple. You are give a function f(A, n), where A is an array of integers and n is the number of elemen…
1188 - Fast Queries    PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 64 MB Given an array of N integers indexed from 1 to N, and q queries, each in the form i j, you have to find the number of distinct integers from index i to …
1100 - Again Array Queries   PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 MB Given an array with n integers, and you are given two indices i and j (i ≠ j) in the array. You have to find two integers in the range whose diffe…
Description 某只同学在生日宴上得到了一个N×N玻璃棋盘,每个单元格都有灯.每一秒钟棋盘会有一个单元格被点亮然后熄灭.棋盘中的单元格将以图中所示的顺序点亮.每个单元格上标记的是它在第几秒被点亮. 第一秒棋格(1,1)将被点亮,第五秒棋格(3,1)将被点亮. 现在这只同学想知道在给定的时间哪个棋格将被点亮(时间将以秒为单位给出).题目假设N足够大. Input 先输入一个整数T(<= 200) , 表示测试用例的组数. 每一组用例将包括一个整数S(1 ≤ S ≤ 1015),表示时间.…
题意: 求前n项的n/i  的和 只取整数部分 暴力肯定超时...然后 ...现在的人真聪明...我真蠢 觉得还是别人的题意比较清晰 比如n=100的话,i=4时n/i等于25,i=5时n/i等于20,于是在大于20到小于等于25内的5个数字j都有n/j等于4,然后ans+=4*5 所以我们可以在小于等于根号n的范围内枚举i,ans+=n/i,然后ans+=(n/(i)-n/(i+1))*i,这样分段加起来 但是又重复的部分.. 即 令m = sqrt(n), 如果n / m == m 则n /…
You are given a tree with N nodes. The tree nodes are numbered from 1 to N and have colors C1, C2,. . . , CN initially. You have to handle M instructions on the tree of the following forms:• 0 u c: Change the color of node u to c.• 1 u v: Output the…
链接: https://vjudge.net/problem/LightOJ-1410 题意: In a 2D plane N persons are standing and each of them has a gun in his hand. The plane is so big that the persons can be considered as points and their locations are given as Cartesian coordinates. Each…