C - Flip,Flip, and Flip......

只有一个这一个是反面

只有一行那么除了两边以外都是反面

否则输出\((N - 2)*(M - 2)\)

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
res = 0;char c = getchar();T f = 1;
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
} int64 N,M;
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
read(N);read(M);
int64 ans = 0;
if(N > M) swap(N,M);
if(N == 1 && M == 1) {puts("1");enter;}
else if(N == 1) {
out(M - 2);enter;
}
else {
out((N - 2) * (M - 2));enter;
}
return 0;
}

D - Remainder Reminder

枚举模数,显然模数需要大于K

对于一个模数小于它的\(i - K\)都合法,如果\(K = 0\)那么是\(i - K - 1\)

对于大于等于它的,我们找到倍数在\(\lfloor\frac{N}{i}\rfloor - 1\)的部分,然后对于\(\lfloor \frac{N}{i} \rfloor \cdot i + K\)统计到N之间的个数

#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
res = 0;char c = getchar();T f = 1;
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9') {
res = res * 10 + c - '0';
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int N,K;
int64 ans;
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
read(N);read(K);
for(int i = 1 ; i <= N ; ++i) {
if(i <= K) continue;
ans += i - K;if(K == 0) --ans;
int t = N / i - 1;
ans += t * (i - K);
t = N / i * i + K;
if(t <= N) ans += N - t + 1;
}
out(ans);enter;
return 0;
}

E - LISDL

最长下降子序列是由几个最长上升子序列拼出来的

如果最长上升子序列长度为A

那么最长下降子序列最多可以有\(N - A + 1\)个

最少可以有\(\lceil \frac{N}{A}\rceil\)个,这中间的都可以通过给\(B\)个最长上升子序列分配个数实现

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <ctime>
#define fi first
#define se second
#define pii pair<int,int>
//#define ivorysi
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 300005
using namespace std;
typedef long long int64;
typedef double db;
typedef unsigned int u32;
template<class T>
void read(T &res) {
res = 0;T f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9' ) {
res = res * 10 - '0' + c;
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int N,A,B;
int cnt[MAXN];
void Solve() {
read(N);read(A);read(B);
int d = (N - 1) / A + 1,u = N - A + 1;
if(B > u || B < d) {puts("-1");return;}
cnt[1] = A;
int t = N - A;
for(int i = 2 ; i <= B ; ++i) {
cnt[i] = t - A >= B - i ? A : t - (B - i);
t -= cnt[i];
}
t = N;
for(int i = B ; i >= 1 ; --i) {
for(int j = t - cnt[i] + 1 ; j <= t ; ++j) {
out(j);space;
}
t -= cnt[i];
}
enter;
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
return 0;
}

F - Strange Nim

如果你有出色的打表技巧可以通过本题

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <ctime>
#define fi first
#define se second
#define pii pair<int,int>
//#define ivorysi
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 300005
using namespace std;
typedef long long int64;
typedef double db;
typedef unsigned int u32;
template<class T>
void read(T &res) {
res = 0;T f = 1;char c = getchar();
while(c < '0' || c > '9') {
if(c == '-') f = -1;
c = getchar();
}
while(c >= '0' && c <= '9' ) {
res = res * 10 - '0' + c;
c = getchar();
}
res *= f;
}
template<class T>
void out(T x) {
if(x < 0) {x = -x;putchar('-');}
if(x >= 10) {
out(x / 10);
}
putchar('0' + x % 10);
}
int N;
int dfs(int a,int x) { if(a < x) return 0;
if(a % x == 0) return a / x;
int t = a / x,h = a % x;
//out(a);space;out(t);space;out(h);enter;
dfs(a - ((h - 1) / (t + 1) + 1) * (t + 1),x);
}
void Solve() {
read(N);
int ans = 0;
int a,k;
for(int i = 1 ; i <= N ; ++i) {
read(a);read(k);
ans ^= dfs(a,k);
}
if(!ans) puts("Aoki");
else puts("Takahashi");
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
Solve();
return 0;
}
05-08 15:34