A. Little Elephant and Function time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant enjoys recursive functions. This time he enjoys the sorting function. Let a is a permuta…
A - Little Elephant and Function 思路: 水题: 代码: #include <cstdio> #include <iostream> using namespace std; int n; int main() { scanf("%d",&n); printf("%d ",n); ;i<n;i++) printf("%d ",i); ; }…
The Little Elephant likes permutations. This time he has a permutation A[1], A[2], ..., A[N] of numbers 1, 2, ...,N. He calls a permutation A good, if the number of its inversions is equal to the number of its local inversions. The number of inversio…
The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent build…
这个题最优策略一定是向左上走到某一列再往上一直走. n*q在线暴力可做,离线按y排序,单调栈维护凸壳. 具体来说:对于i<j若A[i]>A[j] 即j的斜率小而且纵截距小,一定比i优,并且易得栈里直线的交点一定是递增的. 然后直接在交点二分即可. #include<cstdio> #include<algorithm> #define N 500005 #define int long long using namespace std; int s[N],top,a[N…
#237. Delete Node in a Linked List Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the lin…
原题链接在这里:https://leetcode.com/problems/basic-calculator-ii/ Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division sh…
A. Little Elephant and Function 逆推. B. Little Elephant and Numbers \(O(\sqrt n)\)枚举约数. C. Little Elephant and Problem 排序后对应不相等的位置为2,且两数交换. D. Little Elephant and Array 离线+分块. E. Little Elephant and Shifts 每个数单独考虑. 假设\(x\)在数组\(a\)的位置\(i\),在数组\(b\)的位置\…
CodeChef-LECOINS Little Elephant and Colored Coins Little Elephant and Colored Coins The Little Elephant from the Zoo of Lviv very likes coins. But most of all he likes colored coins. He has N types of coins, numbered from 1 to N, inclusive. The coin…
Little Elephant and Broken Sorting 怎么感觉这个状态好难想到啊.. dp[ i ][ j ]表示第 i 个数字比第 j 个数字大的概率.转移好像比较显然. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #define mk make_pair…
更好的阅读体验 Portal Portal1: Codeforces Portal2: Luogu Description The Little Elephant loves playing with arrays. He has array \(a\), consisting of \(n\) positive integers, indexed from \(1\) to \(n\). Let's denote the number with index \(i\) as \(a_i\).…
Sigma Function Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1336 Description Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This fu…
Function Problem Description The shorter, the simpler. With this problem, you should be convinced of this truth. You are given an array A of N postive integers, and M queries in the form (l,r). A function F(l,r) (1≤l≤r≤N) is defined as:F(l,r)={A…
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coord…
GTW likes function 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5596 Description Now you are given two definitions as follows. f(x)=∑xk=0(−1)k22x−2kCk2x−k+1,f0(x)=f(x),fn(x)=f(fn−1(x))(n≥1) Note that φ(n) means Euler's totient function.(φ(n)is an…
M. Heaviside Function Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/M Description Heaviside function is defined as the piecewise constant function whose value is zero for negative argument and one for non-negat…