Codeforces Round #642 (Div. 3) 参与排名人数11823
[codeforces 1353A] Most Unstable Array 照着葫芦画瓢
总目录详见https://blog.csdn.net/mrcrack/article/details/103564004
在线测评地址http://codeforces.com/contest/1353/problem/A
Problem | Lang | Verdict | Time | Memory |
---|---|---|---|---|
A - Most Unstable Array | GNU C++17 | Accepted | 15 ms | 3600 KB |
怎么构造数组,样例已经给出了示范,样例模拟如下
1 100
构造数组如下
100
输出0
2 2
构造数组如下
0 2
输出2
5 5
构造数组如下
0 5 0 0 0
输出10
2 1000000000
构造数组如下
0 1000000000
输出1000000000
1000000000 1000000000
构造数组如下
0 1000000000 0 0 0 ......
输出2000000000
AC代码如下
#include <stdio.h>
int main(){
int t,n,m;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
if(n==1)printf("0\n");
else if(n==2)printf("%d\n",m);
else printf("%d\n",2*m);
}
return 0;
}