-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCOINTOSS.cpp
More file actions
24 lines (23 loc) · 733 Bytes
/
COINTOSS.cpp
File metadata and controls
24 lines (23 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<stdio.h>
int main(){
int t,m,n;
long long int temp=0;
scanf("%d",&t);
for(;t>0;t--){
scanf("%d %d",&n,&m);
temp=0;
if(n==m){printf("0.00\n\n");continue;}
if(m==0){
for(int i=1;i<=n;i++){
temp+=(1<<i);
}
printf("%lld.00\n\n",temp);
}else{
for(int i=1;i<=n;i++){
temp+=(1<<i);
}
printf("%lld.00\n\n",n-m+(temp>>1));
}
}
return 0;
}