稻花香里说丰年,听取WA声一片。

B3871 [GESP202309 五级] 因数分解

hh
by __Eun__ @ 2024-05-01 16:04:45


@[__Eun__](/user/1235464) 没有什么好笑的,讨论区求调是什么好笑的事情吗
by __Tonycyt__ @ 2024-05-01 16:10:25


给你改了一下,首先 long long 开的不全,而且 solve 里的第一行应为 lld ,不是 d ```cpp #include <cstdio> #define int long long int cnt, ct; bool p(int x) { if (x == 1) return 0; for (int i = 2; i * i <= x; ++i) { if (x % i == 0) return 0; } return 1; } void solve(long long n) { if (p(n)) printf("%lld", n); else { for (long long i = 2; i * i <= n; ++i) { cnt = 0; if (n % i == 0) { ct++; while (n % i == 0) { cnt++; n /= i; } if (ct != 1) printf(" * "); if (cnt == 1) printf("%lld", i); else printf("%lld^%lld", i, cnt); if (p(n)) printf(" * %lld", n); } } } } long long n; signed main(){ scanf("%lld", &n); solve(n); return 0; } ``` @[cao_20115](/user/1251905)
by kexun_kevin @ 2024-05-01 16:12:06


这样是70分 ```cpp #include <cstdio> int cnt, ct; void solve(long long n) { for (long long i = 2; i <= n; ++i) { cnt = 0; if (n % i == 0) { ct++; while (n % i == 0) { cnt++; n /= i; } if (ct != 1) printf(" * "); if (cnt == 1) printf("%lld", i); else printf("%lld^%lld", i, cnt); } } } long long n; int main(){ scanf("%lld", &n); solve(n); return 0; } ```
by __Tonycyt__ @ 2024-05-01 16:14:30


@[kexun_kevin](/user/674527) 谢谢~
by cao_20115 @ 2024-05-01 16:18:34


@[__Tonycyt__](/user/667037) 《稻花香里说丰年,听取WA声一片》我在笑这个
by __Eun__ @ 2024-05-01 16:26:05


```cpp #include <cstdio> int cnt, ct; bool p(long long x) { if (x == 1) return 0; for (long long i = 2; i * i <= x; ++i) { if (x % i == 0) return 0; } return 1; } void solve(long long n) { if (p(n)) printf("%lld", n); else { for (long long i = 2; i < n; ++i) { cnt = 0; if (n % i == 0) { ct++; while ((n % i == 0) && (n > 1)) { cnt++; n /= i; } if (ct != 1) printf(" * "); if (cnt == 1) printf("%lld", i); else printf("%lld^%lld", i, cnt); if (p(n)) printf(" * %lld", n); } if (n == 1) return; } } } long long n; int main(){ scanf("%lld", &n); solve(n); return 0; } ``` …… TLE了
by cao_20115 @ 2024-05-01 19:38:42


@[__Eun__](/user/1235464) 笑什么
by cao_20115 @ 2024-05-01 19:39:25


@[cao_20115](/user/1251905) 《稻花香里说丰年,听取WA声一片》这个
by __Eun__ @ 2024-05-02 11:47:05


@[__Eun__](/user/1235464) (lll¬ω¬)
by cao_20115 @ 2024-05-02 11:52:11


| 下一页