Skip to content

Instantly share code, notes, and snippets.

@tanushbanerjee
Created March 3, 2021 10:48
Show Gist options
  • Save tanushbanerjee/46e369487e200f0f3107e0d9ee8480c8 to your computer and use it in GitHub Desktop.
Save tanushbanerjee/46e369487e200f0f3107e0d9ee8480c8 to your computer and use it in GitHub Desktop.
Problems

Competition 1

A: Write a program to print your name. - 100 points

#include <bits/stdc++.h>
using namespace std;
int main() {
  cout << "TANUSH" << "\n";
  return 0;
}

B: Make a Calculator. - 200 points

C: Given 2 integers a and b, find if a is a multiple of b. - 300

D: Write a program in C++ which takes your name, age, height, weight, color of eye as input and print the following :- “Hey, Do you know about ? He is the new cool guy in our school weighing kgs and is cms tall.” “Color of his eye is . I am already looking forward to meeting him today in the evening.” - 400 points Replace with the entries. Use data types which are suitable. - 300 points

E: Write a program in C++ which takes 3 integers x, y, z as the values or measures of the x, y and z axis of a door, print the volume of the door.

F: Write a program in C++ which takes three numbers as input and prints the minimum among them. (Hint: How about nested conditions ? meaning if statement inside of if statement) - 500 points

Competition 2

A: Hello, World !

B: Make a calculator

C: A shop sells a product whose regular price is A yen (Japanese currency) for B yen. By what percentage of the regular price is this product discounted?

/******************************************
 
Author:  					Tanush Banerjee
Email Address:  				samihanbanerjee026@gmail.com
CodeForces Handle: 			samihanbanerjee026
CodeChef Handle: 			tanushbanerjee
AtCoder Handle: 				Tanush_Banerjee
CSES Handle: 				Tanush_Banerjee
 
************Macros And Includes***********/
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " " << x << endl;
#define fo(i, n) for (i = 0; i < n; ++i)
#define Fo(i, k, n) for (i = k; i < n; ++i)
#define rv(a)                          \
  for (int i = 0; i < a.size(); ++i) { \
    cin >> a[i];                       \
  }
#define pb(x) push_back(x);
#define vt vector
 
using ll = long long;
using l = long;
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);
#define ttl  \
  int tt;    \
  cin >> tt; \
  while (tt--)
#define each(x, a) for (auto& x : a)
#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (long long)(x).size()
#define ar array
/*************USEFUL FUNCTIONS**************/
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
 
template <typename... T>
void write(T... args) {
  ((cout << args << " "), ...);
}
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return string(s); }
string to_string(string s) { return s; }
template <typename... T>
void print(T... args) {
  ((cout << args << "\n"), ...);
}
template <class A>
void read(vt<A>& v);
template <class A, size_t S>
void read(ar<A, S>& a);
template <class T>
void read(T& x) {
  cin >> x;
}
void read(double& d) {
  string t;
  read(t);
  d = stod(t);
}
void read(long double& d) {
  string t;
  read(t);
  d = stold(t);
}
template <class H, class... T>
void read(H& h, T&... t) {
  read(h);
  read(t...);
}
template <class A>
void read(vt<A>& x) {
  each(a, x) read(a);
}
template <class A, size_t S>
void read(array<A, S>& x) {
  each(a, x) read(a);
}
template<typename T>
int gcd(T x, T y){T a, b, r;if(x > y){a = x;b = y;}else{a = y;b = x;}while(b != 0){r = a % b;a = b;b = r;}return a;}
/****************DRIVER CODE**************/
void solve() {
  float MP, SP;
  cin >> MP >> SP;
  float DP = (float)(((MP - SP) * 100) / MP);
  printf("%.10f\n", DP);
}
int main() {
  fastio;
  solve();
  return 0;
}

D: Write a program in C++ which calculates the area and circumference of a circle. Use constants and variables. take PI = 3.14 - 600 points

Competition 3:

A: Given an integer find the 3rd power of the integer and print the result;

B: Given 2 strings, find if the first charecter of the first string is equal to the second charecter of the second string.

C: One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.

Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.

Input The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.

Output Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.

D: Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome. Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.

This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.

Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".

You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.

Input The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.

Output Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.

E: Theatre Square in the capital city of Berland has a square shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.

What is the number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square.

Input The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

Output Write the needed number of flagstones.

F: One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution. Otherwise, the friends won't write the problem's solution.

This contest offers 3 problems to the participants. For each problem we know, which friend is sure about the solution. Help the friends find the number of problems for which they will write a solution.

Input The input contains 3 lines contain three integers each, each integer is either 0 or 1. If the first number in the line equals 1, then Petya is sure about the problem's solution, otherwise he isn't sure. The second number shows Vasya's view on the solution, the third number shows Tonya's view. The numbers on the lines are separated by spaces.

Output Print a single integer — the number of problems the friends will implement on the contest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment