UIU Competitive Programmers contest – 03 Solutions


A – Another A+B


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>

int main(int argc, const char * argv[])
{
    int n; 
    
    while (scanf ("%d", &n) != EOF) {
        printf ("%d %d\n", 1, n - 1);
    }

    return 0;
}

// @END_OF_SOURCE_CODE

B – Sum Problem


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>

#define F(i, n) for (int i = 0; i < n; i++)

int main(int argc, const char * argv[])
{
    int n;

    while (scanf ("%d", &n) != EOF) {
        
        int sum = 0;
        
        F(i, n) {
            sum += (i + 1);
        }
        
        printf ("%d\n\n", sum);
    }

    return 0;
}

// @END_OF_SOURCE_CODE

C – Is it a Right Triangle?

https://tausiq.wordpress.com/2013/05/21/uiu-beginners-practice-contest-01-solutions/#b

D – Eddy’s mistakes


// @BEGIN_OF_SOURCE_CODE

#include <iostream>
#include <string>
#include <algorithm>  // transform

using namespace std;

int main(int argc, const char * argv[])
{
    string str;

    // works like, gets in C programming
    while (getline(cin, str)) {

        // make the string lower case
        transform(str.begin(), str.end(), str.begin(), ::tolower);

        cout << str << endl;
    }

    return 0;
}

// @END_OF_SOURCE_CODE

E – f91

https://tausiq.wordpress.com/2013/05/24/uiu-beginners-practice-contest-03-solutions/#h

One thought on “UIU Competitive Programmers contest – 03 Solutions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s