Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a tutorial for dimik-summation #486

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions dimik-summation/en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Dimik - Summation

In this problem, you will be given `T` testcases. Each line of the testcase consists of a 5 digit integer `n`. We just have to print the summation of leftmost and rightmost digit of an integer `n`.

### Solution
We can find the solution by dividing the integer `n` by 10000 to get the leftmost digit and finding the remainder of `n` being divided by 10, we get the rightmost digit. Once we obtain both the digits, we can add them and print them in the format `Sum = summation of both digits`.

### C++
```cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
for (int k = 1; k <= t; k++)
{
int n;
cin >> n;
int sum = 0;
sum += n / 10000;
sum += n % 10;
cout << "Sum = " << sum << endl;
}
}
```