UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#211147#3800. 蛋糕181126062311002564ms48068kbC++111.6kb2024-08-09 12:26:522024-08-09 12:59:59

answer

#include <bits/stdc++.h>
using namespace std;
int x, y, t = 18, genshin, ans[1000001], cnt, wz[10000001], st, ed, xx[1000001];
signed main()
{
    while (t--)
    {
        scanf("%d %d", &x, &y);
        printf("%d", x / y);
        if (x % y == 0)
        {
            puts("");
            continue;
        }
        if (x > y)
        {
            x = x - y * (x / y);
        }
        printf(".");
        //genshin = __gcd(x, y);
        //x /= genshin, y /= genshin;
        memset(wz, 0, sizeof(wz));
        cnt = 0;
        // cout<<x<<' '<<y<<endl;
        while (1)
        {
            x *= 10;
            ans[++cnt] = (x / y) + '0';
            //cout<<cnt<<' '<<x<<' '<<y<<endl;
            if (wz[x])
            {
                st = wz[x];
                ed = cnt;
                break;
            }
            else
            {
                wz[x] = cnt;
                xx[cnt] = x;
            }
            x = x - y * (x / y);
            if (x % y == 0)
            {
                st = ed = 0;
                break;
            }
            if (x < y)
            {
                continue;
            }
        }
        for (int i = 1; i <= cnt; i++)
        {
            if (i == st)
            {
                printf("(");
            }
            if (i == ed)
            {
                printf(")");
                break;
            }
            putchar(ans[i]);
        }
        puts("");
       // for(int i=1;i<=cnt;i++)
       // {
         //   wz[xx[i]]=0;
       // }
    }
    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 5
Accepted
time: 0ms
memory: 1196kb

input:

85 85
59 59
52 52
96 12
62 31
48 24
85 85
85 85
69 69
76 38
72 24
54 27
100 20
72 72
42 42
81 81
78 ...

output:

1
1
1
8
2
2
1
1
1
2
3
2
5
1
1
1
1
1

result:

ok 18 tokens

Test #2:

score: 5
Accepted
time: 1ms
memory: 1192kb

input:

9696 9696
9036 9036
4771 4771
7751 7751
9073 9073
9085 9085
6444 358
4581 4581
8505 8505
8028 2007
9...

output:

1
1
1
1
1
1
18
1
1
4
2
5
2
1
1
1
1
1

result:

ok 18 tokens

Test #3:

score: 5
Accepted
time: 0ms
memory: 1192kb

input:

648044 648044
949839 949839
401844 401844
916962 916962
875649 875649
227737 227737
827552 827552
64...

output:

1
1
1
1
1
1
1
1
1
1
2
7
2
2
5
2
1
2

result:

ok 18 tokens

Test #4:

score: 5
Accepted
time: 70ms
memory: 40268kb

input:

37 25
43 10
56 10
47 2
50 50
66 80
34 50
3 8
56 1
49 10
97 5
10 1
76 40
52 50
70 5
26 1
97 32
32 64

output:

1.48
4.3
5.6
23.5
1
0.825
0.68
0.375
56
4.9
19.4
10
1.9
1.04
14
26
3.03125
0.5

result:

ok 18 tokens

Test #5:

score: 5
Accepted
time: 106ms
memory: 40268kb

input:

451 100
844 50
744 100
874 8
19 625
443 400
415 512
766 625
189 5
71 128
247 80
307 640
395 160
101 ...

output:

4.51
16.88
7.44
109.25
0.0304
1.1075
0.810546875
1.2256
37.8
0.5546875
3.0875
0.4796875
2.46875
6.31...

result:

ok 18 tokens

Test #6:

score: 5
Accepted
time: 131ms
memory: 40264kb

input:

7819 400
2868 512
4833 800
6024 6250
3285 8000
9721 125
4037 6250
8159 1250
4544 3125
6659 5000
8331...

output:

19.5475
5.6015625
6.04125
0.96384
0.410625
77.768
0.64592
6.5272
1.45408
1.3318
41.655
2.14656
12.83...

result:

ok 18 tokens

Test #7:

score: 5
Accepted
time: 113ms
memory: 40264kb

input:

562036 800
494900 160000
710305 4096
549145 125000
277786 125
375881 390625
992034 2
702342 3125
569...

output:

702.545
3.093125
173.414306640625
4.39316
2222.288
0.96225536
496017
224.74944
7.1238125
47.119168
1...

result:

ok 18 tokens

Test #8:

score: 5
Accepted
time: 121ms
memory: 40264kb

input:

910 999
944 999
1978 999
581 999
482 999
380 999
130 999
838 999
326 999
1097 999
568 999
358 999
11...

output:

0.(910)
0.(944)
1.(979)
0.(581)
0.(482)
0.(380)
0.(130)
0.(838)
0.(326)
1.(098)
0.(568)
0.(358)
0.(0...

result:

ok 18 tokens

Test #9:

score: 5
Accepted
time: 110ms
memory: 40264kb

input:

8452 9999
4205 9999
4177 9999
73522 9999
2260 9999
9992 9999
45229 9999
6275 9999
1886 9999
63203 99...

output:

0.(8452)
0.(4205)
0.(4177)
7.(3529)
0.(2260)
0.(9992)
4.(5233)
0.(6275)
0.(1886)
6.(3209)
0.(6995)
0...

result:

ok 18 tokens

Test #10:

score: 5
Accepted
time: 103ms
memory: 40268kb

input:

652832 99999
86603 99999
698815 99999
733498 99999
81815 99999
208109 99999
37024 99999
4883 99999
7...

output:

6.(52838)
0.(86603)
6.(98821)
7.(33505)
0.(81815)
2.(08111)
0.(37024)
0.(04883)
7.(44120)
0.(87916)
...

result:

ok 18 tokens

Test #11:

score: 5
Accepted
time: 80ms
memory: 40272kb

input:

103 491
83 1
114 757
214 7
851 243
672 391
532 3
130 61
385 577
119 233
398 241
607 559
460 1
3 717
...

output:

0.(2097759674134419551934826883910386965376782077393075356415478615071283095723014256619144602851323...

result:

ok 18 tokens

Test #12:

score: 5
Accepted
time: 106ms
memory: 40296kb

input:

4173 2067
5038 4221
9002 4023
5399 8061
3182 4767
6110 1191
2345 1919
2234 8581
2139 4047
5103 8841
...

output:

2.(0188679245283)
1.(193556029376924899312959014451551764984600805496327884387585880123)
2.(23763360...

result:

ok 18 tokens

Test #13:

score: 5
Accepted
time: 142ms
memory: 43180kb

input:

122878 63889
743422 282861
708740 16059
224329 125883
600815 5271
229177 746563
135403 246477
916903...

output:

1.(9233044812095978963514846061137284978634819765530842555056425988824367261969979182644899748000438...

result:

ok 18 tokens

Test #14:

score: 5
Accepted
time: 94ms
memory: 40268kb

input:

792 834
521 262
307 500
269 340
155 96
414 536
173 96
137 735
187 321
577 788
787 958
811 192
563 28...

output:

0.(9496402877697841726618705035971223021582733812)
1.9(885496183206106870229007633587786259541984732...

result:

ok 18 tokens

Test #15:

score: 5
Accepted
time: 94ms
memory: 40264kb

input:

1985 1210
1986 723
1986 628
1988 52
1991 1026
1989 519
1989 1226
1989 21
1984 712
1996 27
1996 816
1...

output:

1.6(4049586776859504132231)
2.(746887966804979253112033195020)
3.1(624203821656050955414012738853503...

result:

ok 18 tokens

Test #16:

score: 5
Accepted
time: 125ms
memory: 40312kb

input:

9941 8960
4951 2688
5659 3776
6203 4096
3449 8816
1517 2269
8977 5183
4189 3777
4928 9496
37 9552
89...

output:

1.10948660(714285)
1.8418898(809523)
1.498675(847457627118644067796610169491525423728813559322033898...

result:

ok 18 tokens

Test #17:

score: 5
Accepted
time: 126ms
memory: 40344kb

input:

80258 62742
8017 18626
10499 36864
27011 55552
32593 37660
61539 72315
2281 51248
45697 64256
3866 3...

output:

1.(2791750342673169487743457333205827037709986930604698606993720314940550189665614739727774058844155...

result:

ok 18 tokens

Test #18:

score: 5
Accepted
time: 113ms
memory: 40412kb

input:

50937 87224
94005 68794
95287 97008
56806 11386
84920 37159
65243 1776
42961 26609
62779 4311
56039 ...

output:

0.583(9791800421902228744382280106392735944235531505090342107676786205631477574979363477941850866733...

result:

ok 18 tokens

Test #19:

score: 5
Accepted
time: 780ms
memory: 48068kb

input:

1000000 999983
999999 999983
999998 999983
999997 999983
999996 999983
999995 999983
999994 999983
9...

output:

1.(0000170002890049130835224198811379793456488760308925251729279397749761745949681144579457850783463...

result:

ok 18 tokens

Test #20:

score: 5
Accepted
time: 149ms
memory: 45688kb

input:

426133 364441
128599 195258
959887 821056
929791 105216
155657 164864
813863 352256
552086 307253
21...

output:

1.(1692784291558853147697432506221857584629610828638929209391918033371656866269162909771403327287544...

result:

ok 18 tokens

Extra Test:

score: 0
Extra Test Passed