Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Aditya Singh_gameofcodes_ps1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define ll long long
#define ull unsigned long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ull mod = 1e9+7;

int main(){

fast;
int t;
cin >> t;
while(t--)
{
int n,a,b,k;
cin >> n >> a >> b >> k;
int avni = 0;
int anuj = 0;
for(int i=0; i<n; i++)
{
int extra;
cin >> extra;
if(extra%a==0 && extra%b!=0)
{
avni++;
}
else if(extra%a!=0 and extra%b==0)
{
anuj++;
}
}

int total = avni+anuj;
if(total >= k)
{
cout << "Win" << nl;
}
else
{
cout << "Lose" << nl;
}

cout << nl;
}
return 0;

}
49 changes: 49 additions & 0 deletions Aditya Singh_gameofcodes_ps2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define ll long long
#define ull unsigned long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ull mod = 1e9+7;

int gcd(int a, int b)
{
if (a == 0 || b == 0)
return 0;

// base case
if (a == b)
return a;

// a is greater
if (a > b)
return gcd(a - b, b);
return gcd(a, b - a);
}

int cpFact(int x, int y)
{
while (gcd(x, y) != 1) {
x = x / gcd(x, y);
}
return x;
}


int main()
{
fast;
int t;
cin >> t;
while(t--)
{
int x, y;
cin >> x >> y;
cout << cpFact(x, y) << nl;

}

cout << nl;
return 0;
}