## Algorithm

Problem Name: beecrowd | 1962

# A Long, Long Time Ago

By M.C. Pinto, UNILA Brazil

Timelimit: 1

Raul Seixas sang that he was born 10 thousand years ago and there was nothing in this world that he cannot know too much. The Mamomas Assassinas band sang that more than 10 thousand years "have gone by and passed" [sic] since they have failed at 5th grade. So many past events and professor MC was curious about what year each of these have happened.

You must write a program that, given a series of how many years have passed, show, for each number, in what year the event had happened. Remember that you must indicate if it had happened BC (Before Christ) or AD (Anno Domini). Use the portuguese A.C. for BC and D.C. for AD according to the output sample.

## Input

The input has several lines. The first one has a positive integer number N (1 ≤ N ≤ 100000). There are N lines after the first one. Each of these N lines has a single non negative integer T, which indicates how many years have passed until 2015 AD (0 ≤ T < 231).

## Output

The output has N lines. In each one there is the year A in which the correspondent time T had happened. Look at the sample output.

 Input Sample Output Sample 3 10000 15 2015 7986 A.C. 2000 D.C. 1 A.C.

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int y;
cin >> y;
if(y >= 2015)
{
cout << y-2014 << " A.C.\n";
}
else{
cout << 2015-y << " D.C.\n";
}
}
return 0;
}
``````
Copy The Code &

Input

cmd
3 10000 15 2015

Output

cmd
7986 A.C. 2000 D.C. 1 A.C.

### #2 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const number = lines.shift();
let i = 0;
let year = lines.shift();

while(i  <  number){
if(year >= 2015){
console.log(`\${year - 2014} A.C.`);
}

else if( year < 2015){
console.log(`\${2015 - year} D.C.`);
}

year = lines.shift(>;
i++
}
``````
Copy The Code &

Input

cmd
3 10000 15 2015

Output

cmd
7986 A.C. 2000 D.C. 1 A.C.

### #3 Code Example with Python Programming

```Code - Python Programming```

``````
for g in range(int(input())):
n = int(input()) - 2014
if n > 0: print(n, 'A.C.');
else: print(-n + 1, 'D.C.')
``````
Copy The Code &

Input

cmd
3 10000 15 2015

Output

cmd
7986 A.C. 2000 D.C. 1 A.C.
Advertisements