百度网盘 做网站图床,河南网站建设价位,小广告的胶怎么清理,宁波公司做企业网站A题是个签到题#xff0c;BC思维题目#xff0c;搞出来结论就秒了#xff0c;D题是个树上DP由于现在水平薄弱还没做出来#xff0c;以后补上
A. Sasha and the Beautiful Array 思路给数组排序#xff0c;然后后项减前项#xff0c;累加值就是最终结果#xff0c;签到题…A题是个签到题BC思维题目搞出来结论就秒了D题是个树上DP由于现在水平薄弱还没做出来以后补上
A. Sasha and the Beautiful Array 思路给数组排序然后后项减前项累加值就是最终结果签到题一个
#includebits/stdc.h
using namespace std;
#define int long long
int t;
int n;
int a[105];
signed main()
{cint;while(t--){cinn;for(int i1;in;i){cina[i];}sort(a1,a1n);int sum0;for(int i2;in;i)suma[i]-a[i-1];coutsum\n;}return 0;
} B. Sasha and the Drawing 我们自己在纸上要是写写画画的话你会发现最多只有前2*n-2次可以一下增加两条对角线后续只能增加一次对角线因此我们需要判断对角线的个数是否小于等于(2*n-2)*2条如果那么每涂一个方框 就能增加两个对角线
我们需要对对角线个数%2进行判断如果整除就直接除如果不整除就1如果大于的话就是至少要2*n-2个方快剩下的多一个对角线就加一个方块
#includebits/stdc.h
using namespace std;
#define int long long
int t;
int n,k;signed main()
{cint;while(t--){cinnk;int sum2*n-2;if(k(2*n-2)*2){if(k%20)coutk/2\n;elsecoutk/21\n;}else{int cnt2*n-2;k-(2*n-2)*2;cntk;coutcnt\n;}}return 0;
}
C. Sasha and the Casino 题解也是一道思维题我们要确保最后盈利如果盈利的话是不是只要我们最终能够盈利就OK了那么我们就需要确保每次投钱假如赢的话一定是可以赚钱的如果输的话就距离自己的大保底更近一步我们的大保底就是输了x把但是最后一次全部梭哈赚回来因此我们只需要确保每次赢了都能赚钱以及假如前面全输大保底也能赚回来就OK了
还有就是开unsigned long long 不然数据会超出范围long long 也不行
#includebits/stdc.h
using namespace std;
#define int long long unsigned
unsigned long long t;
unsigned long long k,x,num;
unsigned long long a[105];
unsigned long long pre[105];
unsigned long long sum;
signed main()
{cint;while(t--){cinkxnum;a[1]1;pre[1]1;unsigned long long z0;for(int i2;ix;i){z(pre[i-1])/(k-1)1;pre[i]pre[i-1]z;a[i]z;}if(numpre[x]){coutNO\n;continue;}if((num-pre[x])*knum){coutNO\n;continue;}coutYES\n;}return 0;
}