1 #include<iostream>
2 #include<memory.h>
3 using namespace std;
4 char a[ 100010];
5 bool b[ 100010];
6 void fn( int n)
7 {
8 memset(b, false, sizeof(b));
9 if(n == 1) cout<< 1<<endl;
10 else
11 {
12 a[ 0] = ' 0 '; a[ 1] = ' . '; b[ 1] = true;
13 int carry = 1;
14 int j = 1, k = 2;
15 while(carry)
16 {
17 carry *= 10;
18 a[k++] = carry / n + ' 0 ';
19 carry = carry % n;
20 if(b[carry]) break;
21 b[carry] = true;
22 }
23 a[k] = ' \0 ';
24 cout<<a<<endl;
25 }
26 }
27
28 int main()
29 {
30 int n,t;
31 cin>>t;
32 while(t--)
33 {
34 cin>>n;
35 if(n< 0){n = -n; cout<< " - ";}
36 fn(n);
37 }
38 return 0;
39 }
2 #include<memory.h>
3 using namespace std;
4 char a[ 100010];
5 bool b[ 100010];
6 void fn( int n)
7 {
8 memset(b, false, sizeof(b));
9 if(n == 1) cout<< 1<<endl;
10 else
11 {
12 a[ 0] = ' 0 '; a[ 1] = ' . '; b[ 1] = true;
13 int carry = 1;
14 int j = 1, k = 2;
15 while(carry)
16 {
17 carry *= 10;
18 a[k++] = carry / n + ' 0 ';
19 carry = carry % n;
20 if(b[carry]) break;
21 b[carry] = true;
22 }
23 a[k] = ' \0 ';
24 cout<<a<<endl;
25 }
26 }
27
28 int main()
29 {
30 int n,t;
31 cin>>t;
32 while(t--)
33 {
34 cin>>n;
35 if(n< 0){n = -n; cout<< " - ";}
36 fn(n);
37 }
38 return 0;
39 }