added 1957A and B

This commit is contained in:
ShazidMahsrafi 2024-04-22 02:25:22 +06:00
parent 60f28d5c5a
commit 292714ad4d
3 changed files with 109 additions and 5 deletions

View File

@ -0,0 +1,46 @@
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "Debug.h"
#else
#define dbg(...)
#endif
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define PI 3.141592653589793238
#define MOD 1000000007
#define FAST (ios_base:: sync_with_stdio(false),cin.tie(NULL));
ull mypow(ull a,ull b,ull m=MOD) {ull ans=1; a%=m; while(b){if(b&1) ans=(ans*a)%m; a=(a*a)%m; b>>=1;} return ans;}
void solve()
{
int n;
cin>>n;
map<int,int>m;
for(int i=0; i<n; ++i)
{
int x;
cin>>x;
m[x]++;
}
int ans=0;
for(auto x:m)
ans += x.ss/3;
cout<<ans<<endl;
}
signed main()
{
FAST;
int TC = 1;
cin >> TC;
while (TC--) solve();
}

View File

@ -0,0 +1,53 @@
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "Debug.h"
#else
#define dbg(...)
#endif
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define PI 3.141592653589793238
#define MOD 1000000007
#define FAST (ios_base:: sync_with_stdio(false),cin.tie(NULL));
ull mypow(ull a,ull b,ull m=MOD) {ull ans=1; a%=m; while(b){if(b&1) ans=(ans*a)%m; a=(a*a)%m; b>>=1;} return ans;}
void solve()
{
int n,k;
cin>>n>>k;
if(n==1)
{
cout<<k<<endl;
return;
}
if(k==1)
{
for(int i=0; i<n-1; ++i)
cout<<0<<" ";
cout<<1<<endl;
return;
}
int x=log2(k);
x--;
int r=(2<<x)-1;
for(int i=0; i<n-2; ++i)
cout<<0<<" ";
cout<<r<<" "<<k-r<<endl;
}
signed main()
{
FAST;
int TC = 1;
cin >> TC;
while (TC--) solve();
}

View File

@ -300,13 +300,18 @@ This repository contains my solutions of Codeforces problems. They are in C++ la
| 288 | 1956 A | Nene's Game | [Question](https://codeforces.com/problemset/problem/1956/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1956%20A%20-%20Nene's%20Game)
| 289 | 1956 B | Nene and the Card Game | [Question](https://codeforces.com/problemset/problem/1956/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1956%20B%20-%20Nene%20and%20the%20Card%20Game)
| 290 | 1956 C | Nene's Magical Matrix | [Question](https://codeforces.com/problemset/problem/1956/C) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1956%20C%20-%20Nene's%20Magical%20Matrix)
| 291 | 1957 A | Stickogon | [Question](https://codeforces.com/problemset/problem/1957/A) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1957%20A%20-%20Stickogon)
| 292 | 1957 B | A BIT of a Construction | [Question](https://codeforces.com/problemset/problem/1957/B) | [Solution](https://github.com/ShazidMashrafi/Codeforces-Solutions/tree/master/Codes/1957%20B%20-%20A%20BIT%20of%20a%20Construction)
# Codeforces Solutions
This repository contains my solutions of Codeforces problems. They are in C++ language.
</div>
#### If this repository helped you out, please consider giving it a :star:
## About Me :eyes:
<div align="center">
I am Shazid Mashrafi.
I am currently studying Computer Science and Engineering & trying to work my way up in the programming world.
Visit my [Website](https://shazidmashrafi.com) and [Codeforces](https://codeforces.com/profile/ShazidMashrafi) account.
## Index
#### Sorted by Problem ID
| Index | Problem ID | Problem Name | Question | Solution |
| :-----: | :--------: | :----------: | :------: | :------: |