-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1583-Digit_Generator.cpp
131 lines (113 loc) · 3.54 KB
/
1583-Digit_Generator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* FILE: Digit_Generator-1583.cpp
*
* @author: Arafat Hasan Jenin <arafathasanjenin[at]gmail[dot]com>
*
* LINK:
*
* DATE CREATED: 06-08-17 13:35:18 (BST)
* LAST MODIFIED: 06-08-17 14:15:04 (BST)
*
* DESCRIPTION:
*
* DEVELOPMENT HISTORY:
* Date Version Description
* --------------------------------------------------------------------
* 06-08-17 1.0 File Created, Accepted
*
*/
/*
// ___ ___ ___ ___
// / /\ / /\ /__/\ ___ /__/\
// / /:/ / /:/_ \ \:\ / /\ \ \:\
// /__/::\ / /:/ /\ \ \:\ / /:/ \ \:\
// \__\/\:\ / /:/ /:/_ _____\__\:\ /__/::\ _____\__\:\
// \ \:\ /__/:/ /:/ /\ /__/::::::::\ \__\/\:\__ /__/::::::::\
// \__\:\ \ \:\/:/ /:/ \ \:\~~\~~\/ \ \:\/\ \ \:\~~\~~\/
// / /:/ \ \::/ /:/ \ \:\ ~~~ \__\::/ \ \:\ ~~~
// /__/:/ \ \:\/:/ \ \:\ /__/:/ \ \:\
// \__\/ \ \::/ \ \:\ \__\/ \ \:\
// \__\/ \__\/ \__\/
*/
/////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <climits>
#include <cmath>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <utility>
#include <sstream>
#include <algorithm>
#include <stack>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <stdint.h> //uint32_t
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef double lf;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<int> vi;
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0)
#define For(i, a, b) for (__typeof (a) i=a; i<=b; i++)
#define Rof(i, b, a) for (__typeof (a) i=b; i>=a; i--)
#define Rep(i, n) for (__typeof (n) i=0; i<n; i++)
#define Forit(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define all(ar) ar.begin(), ar.end()
#define fill(ar, val) memset(ar, val, sizeof(ar))
#define clr(a) memset(a, 0, sizeof a)
#define nl cout << '\n';
#define sp cout << ' ';
#define gc getchar
#define chk cout << "##########\n"
#define pb push_back
#define debug1(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define sq(a) (a * a)
#define PI acos(-1.0)
#define INF 0x7fffffff
#define MOD 1000000007
#define EPS 1e-10
#define MAX 10000005
////////////////////////// START HERE //////////////////////////
int fun(int n) {
int sum = n;
while (n > 0) {
int tmp = n % 10;
sum += tmp;
n /= 10;
}
return sum;
}
int main() {
__FastIO;
int t, n;
map<int, int> mp;
for (int i = 0; i < 100000; i++) {
int tmp = fun(i);
if (mp.count(tmp) == 0) {
mp[tmp] = i;
} else {
mp[tmp] = min(mp[tmp], i);
}
}
cin >> t;
while (t--) {
cin >> n;
cout << mp[n] << '\n';
}
return 0;
}