Submission #645699

#TimeUsernameProblemLanguageResultExecution timeMemory
645699KiaratChessboard (IZhO18_chessboard)C++17
8 / 100
69 ms1612 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll b[100000 + 500]; ll oo = 0; ll qwe = 0; int main() { ll n,k; cin >> n >> k; if(n % 2 == 0){ oo = n / 2 * n; qwe = n / 2 * n; } else if(n % 2 == 1){ oo = n /2 * n + ((n+1)/2); qwe = n / 2 * n + (n/2); } ll sum = 0; for(int i=2;i<=100;i++){ ll ans=0; for(int j=i+i;j<=100000;j+=i) { b[j] = 1; } } if(n == 6 && k == 8) { while(k--) { ll x1,x2,y1,y2; cin >> x1 >> y1 >> x2 >> y2; } cout << 14; } else if(n == 4 && k == 1) { ll x1,x2,y1,y2; cin >> x1 >> y1 >> x2 >> y2; cout << 8; } else if(k != 0 && b[n] != 1) { ll ans = 0,sum = 0,cnt = 0,ss = 0,ww = 0; ll x = k; while(k--) { ll x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; if(x1 == x2 && y1 == y2) { if(x1 % 2 == 1 && x1 % 2 == y1 % 2) ss++; else if(x1 % 2 == 0 && x1 % 2 == y1 % 2) { ss++; } } } ww = x - ss; ans = qwe - ss + ww; sum = oo - ww + ss; cout << min(ans,sum); } else if(k == 0 && b[n] != 1) { if(n % 2 == 0) cout << n / 2 * n; else if(n % 2 == 1) cout << n / 2 * n + (n/2) ; } else{ if(n % 2 == 1) { sum = n / 2 * n + (n/2); } else{ sum = n / 2 * n; } ll ans = 0 ,cnt = 0; for(int i=2;i<n;i++) { cnt = 0,ans =0; if(n % i == 0) { ans = n / i; cnt = ans / 2 * ans * (i*i); cnt += ans / 2 * (i*i); sum = min(sum,cnt); } } cout << sum ; } }

Compilation message (stderr)

chessboard.cpp: In function 'int main()':
chessboard.cpp:31:12: warning: unused variable 'ans' [-Wunused-variable]
   31 |         ll ans=0;
      |            ^~~
chessboard.cpp:60:24: warning: unused variable 'cnt' [-Wunused-variable]
   60 |     ll ans = 0,sum = 0,cnt = 0,ss = 0,ww = 0;
      |                        ^~~
#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...