답안 #48838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48838 2018-05-19T09:18:35 Z mrtsima22 Chessboard (IZhO18_chessboard) C++17
0 / 100
33 ms 2480 KB
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
long long n;
long long k;
long long ans=lmax,ansT,ansS;
long long a[100003],b[100003],c[100003],d[100004];
vector<long long>v;
long long k1;
int main(){std::ios::sync_with_stdio(false);
cin>>n>>k;
ansT=ansS=0LL;
for(long long i=0;i<k;i++)
{
	cin>>a[i]>>b[i]>>c[i]>>d[i];
a[i]--,b[i]--,c[i]--,d[i]--;	
}
ans=lmax;
for(int j=1;j<n;j++)if(n%j==0){
long long p=j;
ansS=ansT=0LL;

for(int i=0;i<k;i++)
{
	{
		long long q1=(a[i])/p;
		long long q2=(b[i])/p;
		long long q=q1+q2;
		if((q)%2==0)
		{
			ansT++;
		}
		else
		{
			ansS++;
		}
	}	
}
long long O=2*ansT-k;
//---------------
//--------------
if(O+n*n/j/j/2LL*j*j<ans)
ans=O+n*n/j/j/2LL*j*j;
//--------------
O=-O;
//--------------
if(O+(n*n/j/j+1LL)/2LL*j/j<ans)
ans=O+(n*n/j/j+1LL)/2LL*j*j;
}
//cout<<ansT+K-ansS<<" "<<ansS+k-ansT<<endl;

cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 2480 KB Output is correct
2 Correct 11 ms 2480 KB Output is correct
3 Incorrect 21 ms 2480 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 2480 KB Output is correct
2 Correct 11 ms 2480 KB Output is correct
3 Incorrect 21 ms 2480 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Incorrect 2 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -