290A - Mysterious strings - CodeForces Solution


*special problem implementation *1400

Please click on ads to support us..

Python Code:

n=int(input())
if n==1:
    print('Washington')
elif n==2:
    print('Adams')
elif n==3:
    print('Jefferson')
elif n==4:
    print('Madison')
elif n==5:
    print('Monroe')
elif n==6:
    print('Adams')
elif n==7:
    print('Jackson')
elif n==8:
    print('Van Buren')
elif n==9:
    print('Harrison')
elif n==10:
    print('Tyler')
elif n==11:
    print('Polk')
elif n==12:
    print('Taylor')
elif n==13:
    print('Fillmore')
elif n==14:
    print('Pierce')
elif n==15:
    print('Buchanan')
elif n==16:
    print('Lincoln')
elif n==17:
    print('Johnson')
elif n==18:
    print('Grant')
elif n==19:
    print('Hayes')
elif n==20:
    print('Garfield')
elif n==21:
    print('Arthur')
elif n==22:
    print('Cleveland')
elif n==23:
    print('Harrison')
elif n==24:
    print('Cleveland')
elif n==25:
    print('McKinley')
elif n==26:
    print('Roosevelt')
elif n==27:
    print('Taft')
elif n==28:
    print('Wilson')
elif n==29:
    print('Harding')
elif n==30:
    print('Coolidge')
elif n==31:
    print('Hoover')
elif n==32:
    print('Roosevelt')
elif n==33:
    print('Truman')
elif n==34:
    print('Eisenhower')
elif n==35:
    print('Kennedy')
elif n==36:
    print('Johnson')
elif n==37:
    print('Nixon')
elif n==38:
    print('Ford')
elif n==39:
    print('Carter')
else:
    print('Reagan')

C++ Code:

/**
  * Create: Tuesday 2023-02-21-18.36.13 GMT+7
  * Title : A. Mysterious strings
  * Author:
*****/


#include <bits/stdc++.h>

using namespace std;

#ifndef   MY_TEMPLATE
template <typename T>                           ostream& operator << (ostream& os, const stack                 <T>         &stack_)                  {os <<   "[";     int n = (int) stack_.size();      vector <T> archive (n);    stack <T>                              stackCopy_ (stack_);   for (int i=0; i<n; ++i) {archive[stackCopy_.size()-1]=stackCopy_.top();       stackCopy_.pop();}     if (!archive.empty())      {for (auto it=archive.begin(); it!=archive.end()-1; ++it)    {os <<*it <<", ";}     os <<archive.back();}     os <<" ";     return os;}
template <typename T>                           ostream& operator << (ostream& os, const queue                 <T>         &queue_)                  {os << "->[";     int n = (int) queue_.size();      vector <T> archive (n);    queue <T>                              queueCopy_ (queue_);   for (int i=0; i<n; ++i) {archive[queueCopy_.size()-1]=queueCopy_ .front();    queueCopy_.pop();}     if (!archive.empty())      {for (auto it=archive.begin(); it!=archive.end()-1; ++it)    {os <<*it <<", ";}     os <<archive.back();}     os <<" ";     return os;}
template <typename T>                           ostream& operator << (ostream& os, const priority_queue        <T,vector<T>,greater<T>>&Queue_)      {os <<   "[";     int n = (int) Queue_.size();      vector <T> archive (n);    priority_queue<T,vector<T>,greater<T>> QueueCopy_ (Queue_);   for (int i=0; i<n; ++i) {archive[QueueCopy_.size()-1]=QueueCopy_.top();       QueueCopy_.pop();}     if (!archive.empty())      {for (auto it=archive.begin(); it!=archive.end()-1; ++it)    {os <<*it <<", ";}     os <<archive.back();}     os <<" ";     return os;}
template <typename T>                           ostream& operator << (ostream& os, const priority_queue        <T>         &Queue_)                  {os <<   "[";     int n = (int) Queue_.size();      vector <T> archive (n);    priority_queue<T>                      QueueCopy_ (Queue_);   for (int i=0; i<n; ++i) {archive[QueueCopy_.size()-1]=QueueCopy_.top();       QueueCopy_.pop();}     if (!archive.empty())      {for (auto it=archive.begin(); it!=archive.end()-1; ++it)    {os <<*it <<", ";}     os <<archive.back();}     os <<" ";     return os;}
template <typename T>                           ostream& operator << (ostream& os, const vector                <T>         &vector_)                 {os <<   "[";     if (!vector_  .empty())           {for (auto it = vector_  .begin(), i=0; i< (int) vector_   .size()-1; ++i, ++it)         {os <<*it <<", ";}     os << * (vector_   .rbegin());}     os << "]";     return os;}
template <typename T>                           ostream& operator << (ostream& os, const deque                 <T>         &deque_)                  {os <<   "[";     if (!deque_   .empty())           {for (auto it = deque_   .begin(), i=0; i< (int) deque_    .size()-1; ++i, ++it)         {os <<*it <<", ";}     os << * (deque_    .rbegin());}     os << "]";     return os;}
template <typename T>                           ostream& operator << (ostream& os, const set                   <T>         &set_)                    {os <<   "[";     if (!set_     .empty())           {for (auto it = set_     .begin(), i=0; i< (int) set_      .size()-1; ++i, ++it)         {os <<*it <<", ";}     os << * (set_      .rbegin());}     os << "]";     return os;}
template <typename T>                           ostream& operator << (ostream& os, const multiset              <T>         &multiSet_)               {os <<   "[";     if (!multiSet_.empty())           {for (auto it = multiSet_.begin(), i=0; i< (int) multiSet_ .size()-1; ++i, ++it)         {os <<*it <<", ";}     os << * (multiSet_ .rbegin());}     os << "]";     return os;}
template <typename T, typename _>               ostream& operator << (ostream& os, const map                   <T, _>      &map_)                    {os <<   "[";     if (!map_     .empty())           {for (auto it = map_     .begin(), i=0; i< (int) map_      .size()-1; ++i, ++it)         {os <<*it <<", ";}     os << * (map_      .rbegin());}     os << "]";     return os;}
template <typename T, typename _>               ostream& operator << (ostream& os, const multimap              <T, _>      &multiMap_)               {os <<   "[";     if (!multiMap_.empty())           {for (auto it = multiMap_.begin(), i=0; i< (int) multiMap_ .size()-1; ++i, ++it)         {os <<*it <<", ";}     os << * (multiMap_ .rbegin());}     os << "]";     return os;}
template <typename T, typename _>               ostream& operator << (ostream& os, const pair                  <T, _>      &pair_)                   {os <<   "{";                                                                                                                                {os <<pair_.first;     os <<":";   os <<pair_.second;}     os << "}";     return os;}
template <typename T>                           void     quick_debug (ostream& os, const char *name,           const T     &value)                   {os <<"[DEBUG]"   << name <<" = " <<value <<endl;};
template <typename T, typename... Args>         void     quick_debug (ostream& os, const char *name,           const T     &value, Args&&... args)   {os <<"[DEBUG]";  while (*name != ',')    {os << *name++;}     os << " = " << value << endl;    quick_debug (os, name + 1, args...);};
#define  hien(...)                              quick_debug(cerr, " " #__VA_ARGS__, __VA_ARGS__)
#define  endl                                   '\n'
#endif


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

   #define trying_to_make_a_lot_of_mistakes_when_allowed
   #define int long long


   int n=40;

   vector <string> a(n+1);
   a[1]="George Washington";
   a[2]="John Adams";
   a[3]="Thomas Jefferson";
   a[4]="James Madison";
   a[5]="James Monroe";
   a[6]="John Adams";
   a[7]="Andrew Jackson";
   a[8]="Martin Van Buren";
   a[9]="William H. Harrison";
   a[10]="John Tyler";
   a[11]="James Knox Polk";
   a[12]="Zachary Taylor";
   a[13]="Millard Fillmore";
   a[14]="Franklin Pierce";
   a[15]="James Buchanan";
   a[16]="Abraham Lincoln";
   a[17]="Andrew Johnson";
   a[18]="Ulysses S. Grant";
   a[19]="Rutherford B. Hayes";
   a[20]="James Garfield";
   a[21]="Chester A. Arthur";
   a[22]="Grover Cleveland";
   a[23]="Benjamin Harrison";
   a[24]="Grover Cleveland";
   a[25]="William McKinley";
   a[26]="Theodore Roosevelt";
   a[27]="William H. Taft";
   a[28]="Woodrow Wilson";
   a[29]="Warren G. Harding";
   a[30]="Calvin Coolidge";
   a[31]="Herbert Hoover";
   a[32]="Franklin D. Roosevelt";
   a[33]="Harry S. Truman";
   a[34]="Dwight D. Eisenhower";
   a[35]="John F. Kennedy";
   a[36]="Lyndon B. Johnson";
   a[37]="Richard Nixon";
   a[38]="Gerald Ford";
   a[39]="Jimmy Carter";
   a[40]="Ronald Reagan";

   int i; cin >> i;

   string& s=a[i];

   string ans=s.substr(s.find_last_of(' ')+1);

   if(i==8){
      cout <<"Van Buren" <<endl;
   }
   else{
      cout <<ans <<endl;
   }























   return 0;
}


Comments

Submit
0 Comments
More Questions

Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum