导航菜单
首页 >  PS考试真题  > CCF

CCF

CCF-CSP历年真题大全附题解(202312已更)

wisetoro: 因子化简优化,耗时31ms:[code=cpp]#include "bits/stdc++.h"using namespace std;bool iszs(int *k){bool r = 1;for (int i = 2; i < *k; ++i)if (*k % i == 0){r = 0;break;}(*k)++;return r;}int main(){long long n;int q, m;cin >> q;for (int i = 0; i < q; i++){cin >> n >> m;long long w = 1;int p = 2;while (p < n){if (iszs(&p)){int j = 1;int s = p - 1;while (n * 1.0 / s == n / s){s *= (p - 1);++j;}s /= (p - 1);--j;n /= s;if (j >= m)w *= s;if (n < pow(p - 1, m))break;}}cout

相关推荐: