为什么样例1过了,却TLE??????

P5737 【深基7.例3】闰年展示

LSR120218_juruo @ 2023-10-22 22:43:11

cpp

include <iostream>

using namespace std; int x, y, ans, i;

int kunkun(int x, int y) { for ( i = x; i <= y; i++) { if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { ans++; } } cout << ans << endl; }

int ikun(int x, int y) { for ( i = x; i <= y; i++) { if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) { cout << i << " "; } } }

int main() { cin >> x >> y; kunkun(x, y); ikun(x, y); return 0; }


by Miyamizu_Mitsuha @ 2023-10-22 22:46:56

无返回值建议用void


by heyx0201 @ 2023-10-22 22:57:23

希望更丰富的展现?使用 Markdown、KaTeX。


by heyx0201 @ 2023-10-22 23:00:24

@LSR120218_juruo 两个函数返回值全部改 void 就可以了。


by LSR120218_juruo @ 2023-10-28 19:37:39

谢谢大佬


by LSR120218_juruo @ 2023-10-28 19:41:13

过了,谢谢各位大佬


by wsn0429JUDYDADY @ 2023-12-23 23:15:42

@LSR120218_juruo void搞一下


|