Sunday, 27 November 2016

11150 - Cola Uva Problem Solution.


Solution:

#include <bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main(){
    int n;
    while(cin >> n)cout << n+(n/2) << endl;
    return 0;
}

10420 - List of Conquests Uva Problem Solution.


Solution:

#include <bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main(){

    string str,s;
    int n;
    cin >> n;
    map<string,int>m;
    map<string,int>::iterator i;
    for(int i = 0; i < n; i++){
        cin >> s;getline(cin,str);
        m[s]++;
    }
    for(i = m.begin(); i != m.end(); i++)cout << i->first << " " << i->second << endl;
    return 0;
}

10921 - Find the Telephone Uva Problem Solution.


Solution:

#include <bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main(){

    string str;
    while(cin >> str){
        int len = str.length();
        string s = "";
        for(int i = 0; i < len; i++){
            if(str[i] == 'A' || str[i] == 'B' || str[i] == 'C')s += "2";
            else if(str[i] == 'D' || str[i] == 'E' || str[i] == 'F')s += "3";
            else if(str[i] == 'G' || str[i] == 'H' || str[i] == 'I')s += "4";
            else if(str[i] == 'J' || str[i] == 'K' || str[i] == 'L')s += "5";
            else if(str[i] == 'M' || str[i] == 'N' || str[i] == 'O')s += "6";
            else if(str[i] == 'P' || str[i] == 'Q' || str[i] == 'R' || str[i] == 'S')s += "7";
            else if(str[i] == 'T' || str[i] == 'U' || str[i] == 'V')s += "8";
            else if(str[i] == 'W' || str[i] == 'X' || str[i] == 'Y' || str[i] == 'Z')s += "9";
            else s += str[i];
        }
        cout << s << endl;
    }
    return 0;
}

483 - Word Scramble Uva Problem Solution


Solution:

#include <bits/stdc++.h>
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
int main(){
    string str;
    while(getline(cin,str)){
        int len = str.length();
        vector<string>tmp;
        string s = "";
        for(int i = 0; i < len; i++){
            if(str[i] != ' ')s += str[i];
            else {
                reverse(s.begin(),s.end());
                tmp.push_back(s);
                s.clear();
            }
        }
        reverse(s.begin(),s.end());
        tmp.push_back(s);
        int sz = tmp.size();
        for(int i = 0; i < sz; i++){
            cout << tmp[i];
            if(i != sz-1)cout << " ";
        }
        cout << endl;
        str.clear();
    }
    return 0;
}