답안 #342660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342660 2021-01-02T15:36:30 Z koketsu Chessboard (IZhO18_chessboard) C++14
8 / 100
22 ms 364 KB
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const LL Mxn = 1e6 + 7;
const LL Mod = 1e9 + 7;
const LL Inf = 1e14 + 7;

bool Prime(int N){
    bool Used = false;
    if(N == 2) return false;
    for(int i = 2; i <= sqrt(N); i++){
        if(N % i == 0){
            Used = true;
            break;
        }
    }
    return Used;
}

bool Get(int x, int y){
    return (x + y) % 2;
}

void Ans1(int N){
    int Ans = Mxn;
    for(int i = 1; i < N; i++){
        if(N % i == 0){
            Ans = min(Ans, (N * N) / (2 * i * i) * (i * i));
        }
    }
    cout << Ans;
}

void Ans2(int N, int K){
    LL Cnt1 = 0, Cnt2 = 0;
    for(int i = 1, x1, y1, x2, y2; i <= K; i++){
        cin >> x1 >> y1 >> x2 >> y2;
        bool Num = Get(y2, x2);
        if(!Num){
            Cnt2++;
        } else {
            Cnt1++;
        }
    }
    cout << min((N * N) / 2 - Cnt1 + Cnt2, (N * N) / 2 + 1 - Cnt2 + Cnt1);
}

int main(){
    Kultivator;
    LL N, K;
    cin >> N >> K;
    if(!K){
        Ans1(N);
    } else if(!Prime(N)){
        Ans2(N, K);
    }
    //cout << Prime(N);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 22 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -