Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go] 2. A+B问题II - 看不出来我的答案和正确答案有任何区别,但是说代码不通过 #130

Open
tigerinus opened this issue Sep 27, 2023 · 1 comment

Comments

@tigerinus
Copy link

package main

import "fmt"

func main() {
    for {
        var n int
        if _, err := fmt.Scanf("%d", &n); err != nil {
            return
        }
        
        for i := 0; i < n; i++ {
            var a, b int
            if _, err := fmt.Scanf("%d %d", &a, &b); err != nil {
                return
            }
            
            fmt.Println(a + b)
        }
    }
}
========[test0.in]=========
100
-3543 -17732
-23566 -9705
3425 -30929
-15910 20397
0 0
1 -1
-1 1
16846 19268
19777 3611
20811 10225
28426 30096
22460 29806
10089 15157
25034 20362
2944 2802
27086 4111
1408 6789
12703 1863
7452 8227
28327 19646
9278 7266
31805 30538
7161 31574
2095 26441
26048 20730
28061 1578
5333 13522
12814 7983
29699 207
22717 13680
5008 30579
52 31524
29550 5429
32284 19996
7601 4391
27988 23952
17734 20694
25152 23838
15585 21362
14692 26896
23095 22575
13361 32734
6510 17386
22558 13555
5329 2576
17403 180
9417 7356
28546 20927
15368 10271
2352 17264
21512 7461
26195 7594
32180 20309
14691 468
27237 10746
661 26913
271 16512
28334 22549
21437 15904
6165 27461
2362 30912
24109 8542
3857 11028
18145 1640
10168 6666
7809 9292
10505 10597
18892 23700
32497 9127
32334 3955
18028 14645
21740 13317
5297 31414
27325 17879
16041 21180
1051 11178
13478 17062
26106 31604
18002 26309
22905 16296
25318 1469
3511 8631
10652 12078
19432 7639
24166 11668
12712 9219
5856 20332
25998 19011
13187 19353
31237 29741
31004 17669
29271 5036
24189 12683
7691 26368
25203 10261
15985 22534
32248 23041
10875 24762
1705 15306
25806 6394 
2
2 4
9 21
========[test0.out]=========
Expected						      |	Yours
-21275								-21275
-33271								-33271
-27504								-27504
4487								4487
0								0
0								0
0								0
36114								36114
23388								23388
31036								31036
58522								58522
52266								52266
25246								25246
45396								45396
5746								5746
31197								31197
8197								8197
14566								14566
15679								15679
47973								47973
16544								16544
62343								62343
38735								38735
28536								28536
46778								46778
29639								29639
18855								18855
20797								20797
29906								29906
36397								36397
35587								35587
31576								31576
34979								34979
52280								52280
11992								11992
51940								51940
38428								38428
48990								48990
36947								36947
41588								41588
45670								45670
46095								46095
23896								23896
36113								36113
7905								7905
17583								17583
16773								16773
49473								49473
25639								25639
19616								19616
28973								28973
33789								33789
52489								52489
15159								15159
37983								37983
27574								27574
16783								16783
50883								50883
37341								37341
33626								33626
33274								33274
32651								32651
14885								14885
19785								19785
16834								16834
17101								17101
21102								21102
42592								42592
41624								41624
36289								36289
32673								32673
35057								35057
36711								36711
45204								45204
37221								37221
12229								12229
30540								30540
57710								57710
44311								44311
39201								39201
26787								26787
12142								12142
22730								22730
27071								27071
35834								35834
21931								21931
26188								26188
45009								45009
32540								32540
60978								60978
48673								48673
34307								34307
36872								36872
34059								34059
35464								35464
38519								38519
55289								55289
35637								35637
17011								17011
32200								32200


==============================

time_space_table:
/1001/sample.in:Accepted mem=1672k time=10ms
/1001/test0.in:Wrong Answer mem=1672k time=62ms

@tigerinus
Copy link
Author

把 Scanf 改成 Scan 就对了,but why?

package main

import "fmt"

func main() {
    for {
        var n int
        if _, err := fmt.Scan(&n); err != nil {
            break
        }
        
        for i := 0; i < n; i++ {
            var a, b int
            if _, err := fmt.Scan(&a, &b); err != nil {
                break
            }
            
            fmt.Println(a + b)
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant