BZOJ 4915 简单的数字题(数学)

xiaoxiao2021-02-28  131

Description 对任意的四个不同的正整数组成的集合A={a_1,a_2,a_3,a_4 },记S_A=a_1+a_2+a_3+a_4,设n_A是满足a_i+a_j (1<=i < j<=4)|S_A的数对(i,j)的个数,现在有两问第一问:求对于所有由4个不同正整数的集合A,n_A的最大值是多少第二问:我们将给出l,r,求区间l到r内满足n_A为最大值的集合组数。 Input 输入一行 2 个整数 l 和 r,意义如上所述。 0<=l,r<=10^18 Output 输出 2 行,每行一个整数,分别表示2问的答案。 Sample Input 1 30 Sample Output 4 3 Solution Code

#include<cstdio> #include<algorithm> using namespace std; typedef long long ll; int main() { ll l,r; while(~scanf("%lld%lld",&l,&r)) printf("4\n%lld\n",max(r/11-l+1,0ll)+max(r/29-l+1,0ll)); return 0; }
转载请注明原文地址: https://www.6miu.com/read-60527.html

最新回复(0)