Skip to content

Commit ac9aa0f

Browse files
authored
Merge pull request ashutosh97#28 from blacksag/testing4
Testing4
2 parents 4df678f + 5abd82a commit ac9aa0f

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

PINS/problem.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Chef's company wants to make ATM PINs for its users, so that they could use the PINs for withdrawing their hard-earned money. One of these users is Reziba, who lives in an area where a lot of robberies take place when people try to withdraw their money.
2+
3+
Chef plans to include a safety feature in the PINs: if someone inputs the reverse of their own PIN in an ATM machine, the Crime Investigation Department (CID) are immediately informed and stop the robbery. However, even though this was implemented by Chef, some people could still continue to get robbed. The reason is that CID is only informed if the reverse of a PIN is different from that PIN (so that there wouldn't be false reports of robberies).
4+
5+
You know that a PIN consists of N decimal digits. Find the probability that Reziba could get robbed. Specifically, it can be proven that this probability can be written as a fraction P/Q, where P≥0 and Q>0 are coprime integers; you should compute P and Q.
6+
7+
Input
8+
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
9+
The first and only line of each test case contains a single integer N denoting the length of each PIN.
10+
Output
11+
For each test case, print a single line containing two space-separated integers — the numerator P and denominator Q of the probability.
12+
13+
Constraints
14+
1≤T≤100
15+
1≤N≤105
16+
Subtasks
17+
Subtask #1 (10 points): N≤18
18+
Subtask #2 (20 points): N≤36
19+
Subtask #3 (70 points): original constraints
20+
21+
Example Input
22+
1
23+
1
24+
Example Output
25+
1 1
26+
Explanation
27+
Example case 1: A PIN containing only one number would fail to inform the CID, since when it's input in reverse, the ATM detects the same PIN as the correct one. Therefore, Reziba can always get robbed — the probability is 1=1/1.

PINS/solution.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
int main()
5+
{
6+
long tcase;
7+
cin>>tcase;
8+
while(tcase)
9+
{
10+
// <---start form here--->
11+
int n;
12+
cin>>n;
13+
cout<<1<<" "<<1;
14+
for(int i=0;i<n/2;i++)
15+
cout<<0;
16+
cout<<endl;
17+
tcase--;
18+
}
19+
20+
return 0;
21+
}

0 commit comments

Comments
 (0)