酷代码 AI
菜单

=======[cyj0.out]========= Expected | Yours 1 | 1 1 \ 1 ============================== ========[cyj1.out]========= Expected | Yours 1 2 3 4 5 6 8 9 10 12 | 1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 | 15 16 18 20 24 25 16 \ 16 ============================== ========[cyj2.out]========= Expected |

```c #include <stdio.h> int isUgly(int num) { if (num <= 0) return 0; while (num % 2 == 0) num /= 2; while (num % 3 == 0) num /= 3; while (num % 5 == 0) num /= 5; return num == 1; } int main() { int n; scanf("%d", &n); int count = 0; int lineCount = 0; for (int i = 1; i <= n; i++) { if (isUgly(i)) { printf("%6d", i); count++; lineCount++; if (lineCount == 10) { printf("\n"); lineCount = 0; } } } if (lineCount > 0) { printf("\n"); } printf("%d\n", count); return 0; } ``` [2026-01-12 17:56:45 | AI问答 | 221点数解答]

服务商
相关提问
发财导航,免费问AI
实用工具查看更多