Align AtCoder - 4371 Problem Statement You are given N integers; the i-th of them is Ai. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like. Constraint…
题意:给定一个n和m,问你x^j + y^j = z^j 的数量有多少个,其中0 <= x <= y <= z <= m, j = 2, 3, 4, ... n. 析:是一个数学题加分类讨论.首先对 x进行分类讨论. 当 0 = x 时,只要 y = z,就行,那么就有(m+1) * (n-1) 个,因为 y 可能从0取到m ,j 可以从2取到 n. 当 0 != x 时,那么只要一个勾股定理能构成,只要幂大于2,就一下没解,所以我们把第一种中拿出j = 2时,的特殊情况,特殊考…
B. Masha and geometric depression 题意 在黑板上写数列,首项是b,公比是q,超过l时就停止不写.给定m个数,遇到后跳过不写.问一共写多少个数,如果无穷个输出inf. 题解 分类讨论要注意b大于l,则一个也不会写.(仔细读题!! 暴力的话,可以用map或者set,然后遇到重复的就是inf. 代码 const int N = 2000001; ll b,q,u,m; ll a[N]; int main(){ while(~scanf("%lld%lld%lld%ll…