-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1433A.cpp
More file actions
23 lines (19 loc) · 721 Bytes
/
Copy path1433A.cpp
File metadata and controls
23 lines (19 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Created on 15-Feb-24.
//done ac
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int x, digits;
cin >> x;
digits = int(log10(x) + 1); //this counts digits. example 345, 2<log value<3 .then +1
int pressed = ((x % 10) - 1) * 10 + (digits * (digits + 1)) / 2; //first part gets number last digit and then -1
//gives prev digit.means each prev digits were pressed
// 10 times. second part counts current number pressed
cout << pressed<<endl;
}
return 0;
}