제출 #1134184

#제출 시각아이디문제언어결과실행 시간메모리
1134184AgageldiChessboard (IZhO18_chessboard)C++17
8 / 100
12 ms2376 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 400005 #define ff first #define ss second #define pb push_back #define sz(s) (int)s.size() #define rep(c, a, b) for(c = a; c <= b; c++) ll n, t, y, answer, k, jogap = INT_MAX, p, o[N], u[N], z[N], g[N]; vector <int> v; int power(int a,int b) { return a*b; } int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> n >> k; for(int i = 1; i <= k; i++) { cin >> o[i] >> z[i] >> u[i] >> g[i]; } for(int i = 1; i < n; i++) { if(n % i == 0) v.pb(i); } for(auto i : v) { int b = 0; for(int j = 1;j <= k; j++) { t = ((o[j] - 1) / i) % 2; p = ((z[j] - 1) / i) % 2; bool tap = 0; if(t && !p || !t && p) tap = 1; if(!tap) answer++; else b++; } t = power((n/i/2),(n/i + 1)/2) * 2 * i * i; jogap = min(jogap,answer + t - b); b = answer = 0; for(int j = 1;j <= k; j++) { t = ((o[j] - 1) / i) % 2; p = ((z[j] - 1) / i) % 2; bool tap = 1; if(t && !p || !t && p) tap = 0; if(tap) answer++; else b++; } t = power((n/i/2),(n/i + 1)/2) * 2 * i * i; jogap = min(jogap,b + t - answer); } cout << jogap << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...