yukicoder contest 257 Participation record

yukicoder contest 257 Participation record

A 1113 Two Integers

When the number of common divisors is odd, only when the greatest common divisor can be expressed by the square of some number. Isqrt is a function newly implemented in Python 3.8.

from math import gcd, isqrt

A, B = map(int, input().split())

X = gcd(A, B)

if isqrt(X) * isqrt(X) == X:
    print('Odd')
else:
    print('Even')

Since the test is weak, if the greatest common divisor is not divisible by a number less than 10 7 </ sup>, it is output as Odd, otherwise the greatest common divisor is factorized into the number of divisors. You can also AC by asking for. Why isn't there a case where the greatest common divisor is a prime number of 10 9 </ sup> or more, or is it not in the test case? ..

#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
using namespace std;
using ll = long long;

int main() {
    ll A, B;
    cin >> A >> B;

    ll X = gcd(A, B);

    if (X == 1) {
        cout << "Odd" << endl;
        return 0;
    }

    bool flag = false;
    for (ll i = 2; i < 1e7; i++) {
        if (X % i == 0) {
            flag = true;
            break;
        }
    }

    if (!flag) {
        cout << "Odd" << endl;
        return 0;
    }

    ll result = 1;
    ll t = 0;
    while (X % 2 == 0) {
        t++;
        X /= 2;
    }
    result *= t + 1;

    for (ll i = 3; i < (ll)(sqrt(X) + 1); i += 2) {
        if (X % i != 0) continue;

        ll t = 0;
        while (X % i == 0) {
            t++;
            X /= i;
        }
        result *= t + 1;
    }
    if (X != 1) {
        result *= 2;
    }

    if (result % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

    return 0;
}

B 1114 Do not return to the addition tray

The sum of odd numbers is even, so you can win if you give only odd numbers.

N = int(input())

print(*range(1, N + 1, 2))

You can win even if you put out only the second half.

N = int(input())

print(*range(N // 2 + 1, N + 1))

Recommended Posts

yukicoder contest 265 Participation record
yukicoder contest 266 Participation record
yukicoder contest 263 Participation record
yukicoder contest 243 Participation record
yukicoder contest 273 Participation record
yukicoder contest 252 Participation record
yukicoder contest 259 Participation record
yukicoder contest 249 Participation record
yukicoder contest 271 Participation record
yukicoder contest 251 Participation record
yukicoder contest 242 Participation record
yukicoder contest 241 Participation record
yukicoder contest 277 Participation record
yukicoder contest 257 Participation record
yukicoder contest 254 Participation record
yukicoder contest 246 Participation record
yukicoder contest 275 Participation record
yukicoder contest 274 Participation record
yukicoder contest 247 Participation record
yukicoder contest 261 Participation record
yukicoder contest 278 Participation record
yukicoder contest 248 Participation record
yukicoder contest 270 (mathematics contest) Participation record
yukicoder contest 272 (Weird math contest) Participation record
yukicoder contest 256 entry record
yukicoder contest 264 entry record
yukicoder contest 245 entry record
yukicoder contest 250 entry record
yukicoder contest 262 entry record
yukicoder contest 259 Review
yukicoder contest 264 Review
yukicoder contest 261 Review
yukicoder contest 267 Review
yukicoder contest 266 Review
yukicoder contest 263 Review
yukicoder contest 268 Review
AtCoder Beginner Contest 181 Participation Report
AtCoder Beginner Contest 161 Participation Report
AtCoder Beginner Contest 151 Participation Report
AtCoder Beginner Contest 176 Participation Report
AtCoder Beginner Contest 154 Participation Report
AtCoder Beginner Contest # 003 Participation Note
AtCoder Grand Contest 041 Participation Report
AtCoder Beginner Contest 166 Participation Report
AtCoder Grand Contest 040 Participation Report
AtCoder Beginner Contest 153 Participation Report
AtCoder Beginner Contest 145 Participation Report
AtCoder Beginner Contest 184 Participation Report
AtCoder Beginner Contest 165 Participation Report
AtCoder Beginner Contest 169 Participation Report
AtCoder Beginner Contest 178 Participation Report
AtCoder Beginner Contest 163 Participation Report
AtCoder Beginner Contest 159 Participation Report
AtCoder Beginner Contest 164 Participation Report
AtCoder Regular Contest 105 Participation Report
AtCoder Beginner Contest 168 Participation Report
AtCoder Beginner Contest 150 Participation Report
AtCoder Beginner Contest 158 Participation Report
AtCoder Beginner Contest 180 Participation Report
AtCoder Regular Contest 104 Participation Report
AtCoder Beginner Contest 156 Participation Report