Skip to content

Commit a9b4c7f

Browse files
authored
Merge pull request larissalages#2 from larissalages/master
Pull req
2 parents 2b4ca62 + 8c33fc5 commit a9b4c7f

File tree

199 files changed

+7322
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+7322
-118
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#include<bits/stdc++.h>
2+
3+
/*Author - Silent Knight
4+
Institution - Birla Institute Of Technology, Mesra
5+
*/
6+
7+
using namespace std;
8+
typedef long long int ll;
9+
typedef long double ld;
10+
#define pb push_back
11+
12+
ll modInverse(ll n,ll p)
13+
{
14+
ll x = n;
15+
ll y = p-2;
16+
ll res = 1;
17+
x = x % p;
18+
while (y > 0)
19+
{
20+
if (y & 1)
21+
res = (res*x) % p;
22+
y = y>>1;
23+
x = (x*x) % p;
24+
}
25+
return res;
26+
}
27+
28+
29+
ll nCrModPFermat(ll n,ll r,ll p)
30+
{
31+
32+
if (r == 0)
33+
return 1;
34+
35+
ll fac[n+1];
36+
fac[0] = 1;
37+
38+
for (ll i=1 ; i<=n; i++)
39+
fac[i] = fac[i-1]*i%p;
40+
41+
return (fac[n]*modInverse(fac[r], p) % p*modInverse(fac[n-r], p) % p) % p;
42+
}
43+
44+
ll fun1(string s,string k,ll n)
45+
{
46+
ll i,j;
47+
ll a = 0,b = 0,x = 0;
48+
ll g[4]={0};
49+
ll p=1e9+7;
50+
ll sum=0;
51+
52+
for(i=0;i<n;i++)
53+
{
54+
if(s[i]=='1')
55+
a++;
56+
if(k[i]=='1')
57+
b++;
58+
}
59+
60+
if(a>b)
61+
{
62+
x=1;
63+
}
64+
g[0]=(a-b)*x;
65+
g[1]=(1-x)*(b-a);
66+
g[2]=(n-a)*x+(1-x)*(n-b);
67+
g[3]=b*x+(1-x)*a;
68+
69+
do{
70+
sum=(sum+ nCrModPFermat(n, g[0]+g[1], p))%p;
71+
72+
g[0] += 1;
73+
g[1] += 1;
74+
g[2] -= 1;
75+
g[3] -= 1;
76+
}while(g[2]>=0 && g[3]>=0);
77+
78+
return sum;
79+
}
80+
81+
ll power(ll x, ll y, ll p)
82+
{
83+
ll res = 1;
84+
x = x % p;
85+
while (y > 0)
86+
{
87+
if (y & 1)
88+
res = (res*x) % p;
89+
90+
y = y>>1;
91+
x = (x*x) % p;
92+
}
93+
return res;
94+
}
95+
96+
int main()
97+
{
98+
ios_base::sync_with_stdio(false);
99+
cin.tie(NULL);
100+
101+
//sabse bekaar solution of the world!!!!!!
102+
103+
ll t;
104+
cin>>t;
105+
while(t--)
106+
{
107+
ll n;
108+
cin>>n;
109+
ll ans;
110+
if(n%2 == 0)
111+
ans = (n/2) - 1;
112+
else
113+
ans = n/2;
114+
cout<<ans<<"\n";
115+
}
116+
return 0;
117+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#include<bits/stdc++.h>
2+
3+
/*Author - Silent Knight
4+
Institution - Birla Institute Of Technology, Mesra
5+
*/
6+
7+
using namespace std;
8+
typedef long long int ll;
9+
typedef long double ld;
10+
#define pb push_back
11+
12+
ll modInverse(ll n,ll p)
13+
{
14+
ll x = n;
15+
ll y = p-2;
16+
ll res = 1;
17+
x = x % p;
18+
while (y > 0)
19+
{
20+
if (y & 1)
21+
res = (res*x) % p;
22+
y = y>>1;
23+
x = (x*x) % p;
24+
}
25+
return res;
26+
}
27+
28+
29+
ll nCrModPFermat(ll n,ll r,ll p)
30+
{
31+
32+
if (r == 0)
33+
return 1;
34+
35+
ll fac[n+1];
36+
fac[0] = 1;
37+
38+
for (ll i=1 ; i<=n; i++)
39+
fac[i] = fac[i-1]*i%p;
40+
41+
return (fac[n]*modInverse(fac[r], p) % p*modInverse(fac[n-r], p) % p) % p;
42+
}
43+
44+
ll fun1(string s,string k,ll n)
45+
{
46+
ll i,j;
47+
ll a = 0,b = 0,x = 0;
48+
ll g[4]={0};
49+
ll p=1e9+7;
50+
ll sum=0;
51+
52+
for(i=0;i<n;i++)
53+
{
54+
if(s[i]=='1')
55+
a++;
56+
if(k[i]=='1')
57+
b++;
58+
}
59+
60+
if(a>b)
61+
{
62+
x=1;
63+
}
64+
g[0]=(a-b)*x;
65+
g[1]=(1-x)*(b-a);
66+
g[2]=(n-a)*x+(1-x)*(n-b);
67+
g[3]=b*x+(1-x)*a;
68+
69+
do{
70+
sum=(sum+ nCrModPFermat(n, g[0]+g[1], p))%p;
71+
72+
g[0] += 1;
73+
g[1] += 1;
74+
g[2] -= 1;
75+
g[3] -= 1;
76+
}while(g[2]>=0 && g[3]>=0);
77+
78+
return sum;
79+
}
80+
81+
ll power(ll x, ll y, ll p)
82+
{
83+
ll res = 1;
84+
x = x % p;
85+
while (y > 0)
86+
{
87+
if (y & 1)
88+
res = (res*x) % p;
89+
90+
y = y>>1;
91+
x = (x*x) % p;
92+
}
93+
return res;
94+
}
95+
96+
int main()
97+
{
98+
ios_base::sync_with_stdio(false);
99+
cin.tie(NULL);
100+
101+
//sabse bekaar solution of the world!!!!!!
102+
103+
ll t;
104+
cin>>t;
105+
while(t--)
106+
{
107+
ll n,a,b;
108+
cin>>n>>a>>b;
109+
char s[b];
110+
for(ll i=0;i<b;i++)
111+
s[i] = char(97+i);
112+
for(ll i=0;i<n;i++)
113+
{
114+
ll index = i%b;
115+
cout<<s[index];
116+
}
117+
cout<<"\n";
118+
}
119+
return 0;
120+
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#include<bits/stdc++.h>
2+
3+
/*Author - Silent Knight
4+
Institution - Birla Institute Of Technology, Mesra
5+
*/
6+
7+
using namespace std;
8+
typedef long long int ll;
9+
typedef long double ld;
10+
#define pb push_back
11+
12+
ll modInverse(ll n,ll p)
13+
{
14+
ll x = n;
15+
ll y = p-2;
16+
ll res = 1;
17+
x = x % p;
18+
while (y > 0)
19+
{
20+
if (y & 1)
21+
res = (res*x) % p;
22+
y = y>>1;
23+
x = (x*x) % p;
24+
}
25+
return res;
26+
}
27+
28+
29+
ll nCrModPFermat(ll n,ll r,ll p)
30+
{
31+
32+
if (r == 0)
33+
return 1;
34+
35+
ll fac[n+1];
36+
fac[0] = 1;
37+
38+
for (ll i=1 ; i<=n; i++)
39+
fac[i] = fac[i-1]*i%p;
40+
41+
return (fac[n]*modInverse(fac[r], p) % p*modInverse(fac[n-r], p) % p) % p;
42+
}
43+
44+
ll fun1(string s,string k,ll n)
45+
{
46+
ll i,j;
47+
ll a = 0,b = 0,x = 0;
48+
ll g[4]={0};
49+
ll p=1e9+7;
50+
ll sum=0;
51+
52+
for(i=0;i<n;i++)
53+
{
54+
if(s[i]=='1')
55+
a++;
56+
if(k[i]=='1')
57+
b++;
58+
}
59+
60+
if(a>b)
61+
{
62+
x=1;
63+
}
64+
g[0]=(a-b)*x;
65+
g[1]=(1-x)*(b-a);
66+
g[2]=(n-a)*x+(1-x)*(n-b);
67+
g[3]=b*x+(1-x)*a;
68+
69+
do{
70+
sum=(sum+ nCrModPFermat(n, g[0]+g[1], p))%p;
71+
72+
g[0] += 1;
73+
g[1] += 1;
74+
g[2] -= 1;
75+
g[3] -= 1;
76+
}while(g[2]>=0 && g[3]>=0);
77+
78+
return sum;
79+
}
80+
81+
ll power(ll x, ll y, ll p)
82+
{
83+
ll res = 1;
84+
x = x % p;
85+
while (y > 0)
86+
{
87+
if (y & 1)
88+
res = (res*x) % p;
89+
90+
y = y>>1;
91+
x = (x*x) % p;
92+
}
93+
return res;
94+
}
95+
96+
int main()
97+
{
98+
ios_base::sync_with_stdio(false);
99+
cin.tie(NULL);
100+
101+
//sabse bekaar solution of the world!!!!!!
102+
103+
ll t;
104+
cin>>t;
105+
while(t--)
106+
{
107+
ll n;
108+
cin>>n;
109+
ll temp;
110+
map <ll,ll> mp;
111+
set <ll> s;
112+
for(ll i=0;i<n;i++)
113+
{
114+
cin>>temp;
115+
mp[temp] += 1;
116+
s.insert(temp);
117+
}
118+
ll maxi = -1;
119+
for(auto it : mp)
120+
{
121+
maxi = max(maxi,it.second);
122+
}
123+
ll distinct = s.size();
124+
if(n == 1)
125+
cout<<0;
126+
else if(maxi == 1)
127+
{
128+
cout<<maxi;
129+
}
130+
else
131+
{
132+
if(maxi < distinct)
133+
cout<<maxi;
134+
else if(maxi == distinct)
135+
cout<<maxi - 1;
136+
else
137+
cout<<distinct;
138+
139+
}
140+
cout<<"\n";
141+
}
142+
return 0;
143+
}

0 commit comments

Comments
 (0)