-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathhello.cpp
More file actions
81 lines (80 loc) · 2.04 KB
/
hello.cpp
File metadata and controls
81 lines (80 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <time.h>
using namespace std;
#define MOD 1000000007LL
#define LL long long
#define ULL unsigned long long
#define LD long double
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)<0?-(x):(x))
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define DB(x) cout<<"\n"<<#x<<" = "<<(x)<<"\n";
#define CL(a,b) memset(a,b,sizeof(a))
#define GOLD ((1+sqrt(5))/2)
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps (char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
void swapi(int *a,int *b){int temp;temp=*a;*a=*b;*b=temp;}
ULL gcd(ULL a,ULL b){if(a==0)return b;if(b==0)return a;if(a==1||b==1)return 1;
if(a==b)return a;if(a>b)return gcd(b,a%b);else return gcd(a,b%a);}
#define SIZE 1000001
void preprocess()
{
}//end prepreprocess
void refresh()
{
}//end refresh
void compute()
{
LL n,v;
cin>>n>>v;
if(v==1){
cout<<(n*(n-1))/2<<" "<<(n*(n-1))/2<<endl;}
if(v>1){
LL min=0,max;
if((n-1)<=v)
min=n-1;
else{
min=v;
LL p=n-(v+1)+1;
min=min+((p*(p+1))/2)-1;
}
// min=min+((n-i)*(n-1));
max=(n*(n-1))/2;
cout<<max<<" "<<min<<endl;
}
}//end compute
int main()
{
#ifdef debug
freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
freopen("log.txt", "w", stderr);
#endif
int t,i,j;preprocess();
scanf("%d",&t);
while(t--)
{
compute();
}//end while
#ifdef debug
fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
#endif
return 0;
}//end main*