Codechef Practice | Week 1

CODECHEF SOLUTION

Week 1: Codechef Practice

1. Total Prize Money: PRIZEPOOL

link: PRIZEPOOL

#include <iostream>
using namespace std;

int main() {
	int txP;
	cin>>txP;
	for(int index=0;index<txP;index++)
	{
	    int xx,yx;
	    cin>>xx>>yx;
	    cout<<10*xx+90*yx<<endl;
	}
	return 0;

}

2. My very 1st contest: MY1STCONTEST

link: MY1STCONTEST

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int n,a,b;
	cin>>n>>a>>b;
	int p=n-a;
	int k=p-b;
	
	cout<<p<<" ";
	cout<<k<<endl;
	return 0;
}

3. Mutated Minions: CHN15A


link:
CHN15A

#include <bits/stdc++.h>
using namespace std;

#define fin(a, b) for(ll i = a; i < b; i++)
#define fdec(a, b) for(ll i = a; i > b; i--)
#define ll long long
#define vl vector<ll>
#define pb push_back
#define FAST ios::sync_with_stdio(false); cin.tie(0)
const long long M = 1e9 + 7;

signed main()
{
    FAST;
    ll t;
    cin >> t;
    while (t--) {
        ll n, k;
        cin >> n >> k;
        vector<ll> v(n);
        for (auto &i: v) cin >> i;
        ll c = 0;
        for (ll i = 0; i < n; i++) {
            v[i] += k;
            if (v[i] % 7 == 0) ++c;
        }
        cout << c << '\n';
    }
    return 0;
}

4. Primality Test Problem: PRB01

link: PRB01

#include <iostream>
using namespace std;
#define endl '\n'

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,t,i,y;
    cin>>t;
    while(t--)
    {
        cin>>n;
        if(n==1)
            cout<<"no"<<endl;
        else{
            y=0;
            for(i=2; i*i<=n; i++)
            {
                if(n%i==0)
                {
                    y=1;
                    break;
                }
            }
            if(y==0)
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }

    }
    return 0;

}

5. Degree of Polynomial: DPOLY

link: DPOLY

#include <iostream>
using namespace std;
int main() 
{
    int a,t;
    cin>>t;
    for(a=0;a<t;a++)
    {
        int n,a[1000],i;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(i=n-1;i>=0;i--)
        {
            if(a[i]!=0)
            {
                break;
            }
        }
        cout<<i<<endl;
        
    }
    return 0;
}

* The material and content uploaded on this website are for general information and reference purposes only and don’t copy the answers of this website to any other domain without any permission or else copyright abuse will be in action.

Please do it by your own first!

DMCA.com Protection Status

close button
5 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
AdBlock Detected

Looks like you are using an ad-blocking browser extension. We request you to whitelist our website on the ad-blocking extension and refresh your browser to view the content.

0
Would love your thoughts, please comment.x
()
x