题解 | #小红和小紫的取素因子游戏#

小红和小紫的取素因子游戏

https://www.nowcoder.com/practice/6146f391a69547c4804fe8d0330f1745

将 x 分解质因子后判断奇偶即可。

#include<bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 3e5 + 10;
const int M = 1e3 + 10;
int mod = 1e9 + 7;
int a[N];

void solve() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) n /= i, sum++;
    }
    if (n > 1) sum++;
    if (sum % 2) cout << "kou\n";
    else cout << "yukari\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int _;
    _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
}

全部评论

相关推荐

__Offer__:认识的室友啥也不回细节,线下面联想大模型一次通关我给我干不回了
点赞 评论 收藏
分享
11-07 15:54
门头沟学院 Java
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务