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;
}

【AtCoder】ARC091的更多相关文章

  1. 【AtCoder】ARC092 D - Two Sequences

    [题目]AtCoder Regular Contest 092 D - Two Sequences [题意]给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1<=i,j<=n ...

  2. 【Atcoder】CODE FESTIVAL 2017 qual A D - Four Coloring

    [题意]给定h,w,d,要求构造矩阵h*w满足任意两个曼哈顿距离为d的点都不同色,染四色. [算法]结论+矩阵变换 [题解] 曼哈顿距离是一个立着的正方形,不方便处理.d=|xi-xj|+|yi-yj ...

  3. 【AtCoder】ARC 081 E - Don't Be a Subsequence

    [题意]给定长度为n(<=2*10^5)的字符串,求最短的字典序最小的非子序列字符串. http://arc081.contest.atcoder.jp/tasks/arc081_c [算法]字 ...

  4. 【AtCoder】AGC022 F - Leftmost Ball 计数DP

    [题目]F - Leftmost Ball [题意]给定n种颜色的球各k个,每次以任意顺序排列所有球并将每种颜色最左端的球染成颜色0,求有多少种不同的颜色排列.n,k<=2000. [算法]计数 ...

  5. 【AtCoder】AGC005 F - Many Easy Problems 排列组合+NTT

    [题目]F - Many Easy Problems [题意]给定n个点的树,定义S为大小为k的点集,则f(S)为最小的包含点集S的连通块大小,求k=1~n时的所有点集f(S)的和取模92484403 ...

  6. 【AtCoder】ARC067 F - Yakiniku Restaurants 单调栈+矩阵差分

    [题目]F - Yakiniku Restaurants [题意]给定n和m,有n个饭店和m张票,给出Ai表示从饭店i到i+1的距离,给出矩阵B(i,j)表示在第i家饭店使用票j的收益,求任选起点和终 ...

  7. 【AtCoder】ARC095 E - Symmetric Grid 模拟

    [题目]E - Symmetric Grid [题意]给定n*m的小写字母矩阵,求是否能通过若干行互换和列互换使得矩阵中心对称.n,m<=12. [算法]模拟 [题解]首先行列操作独立,如果已确 ...

  8. 【Atcoder】AGC022 C - Remainder Game 搜索

    [题目]C - Remainder Game [题意]给定n个数字的序列A,每次可以选择一个数字k并选择一些数字对k取模,花费2^k的代价.要求最终变成序列B,求最小代价或无解.n<=50,0& ...

  9. 【Atcoder】AGC 020 B - Ice Rink Game 递推

    [题意]n个人进行游戏,每轮只保留最大的a[i]倍数的人,最后一轮过后剩余2人,求最小和最大的n,或-1.n<=10^5. [算法]递推||二分 [题解]令L(i),R(i)表示第i轮过后的最小 ...

随机推荐

  1. 【题解】 bzoj1088: [SCOI2005]扫雷Mine (神奇的做法)

    bzoj1088,懒得复制,戳我戳我 Solution: 其实这个有个结论,答案只会有\(0\),\(1\),\(2\)三种(我真的是个弱鸡,这个都想不到) 然后我们假设第一个就可以推出所有的状态(显 ...

  2. BZOJ 3876 支线剧情 | 有下界费用流

    BZOJ 3876 支线剧情 | 有下界费用流 题意 这题题面搞得我看了半天没看懂--是这样的,原题中的"剧情"指的是边,"剧情点"指的才是点. 题面翻译过来大 ...

  3. 在Mac OS X上用Fluid把网页变成本地App

    最近一直在个在线听音乐的解决方案,也下了很多的本地软件,什么酷狗.酷我.豆瓣.虾米.QQ.百度音乐之类的,下了一大堆,都逐个测试了,效果都不是很理想-- 要么是UI太悲催,要么是对Retina支持不友 ...

  4. bzoj1008/luogu3197 越狱 (快速幂)

    算$m^n-m*(m-1)^{n-1}$,就是总的减去不越狱的,不越狱就每次都选一个和上一个不一样的

  5. [Java] I/O底层原理之三:NIO

    本篇文章参考自并发编程网 一.NIO 的概述 NIO 由以下几个核心组成 Channels Buffers Selectors 选择器用于监听多个通道的事件(如:链接打开.数据达到),单个线程可以监听 ...

  6. python---django中模板渲染(csrf令牌使用,自定义模板函数)

    使用终端,可以更方便的去实验,但是没有提示信息: 在项目目录下: D:\MyPython\day23\HelloWorld>python manage.py shell 开始实验: >&g ...

  7. vue element-ui表格里时间戳转换成时间显示

    工作中遇到后台给的表格数据里时间是一个13位的时间戳,需要转换成时间显示在表格里, 可以用element-ui表格自带的:formatter函数,来格式化表格内容: // 时间戳转换成时间 // 使用 ...

  8. Tomcat get 中文乱码

    乱码问题 原因: tomcat默认的在url传输时是用iso8859-1编码. 解决方案一: 在使用get传输参数时,将参数中的中文转换成url格式,也就是使用urlEncode和urlDecode来 ...

  9. css 基础2

    1.内部样式表: 2.行内样式表:在标签内写style,适合style 比较少的情况 3.外部样式表(外联式): 4.html标签可以分为:块级标签,h1~h6,div ,p,ul,ol,li,div ...

  10. scala 资料集结

    Scala入门到精通 http://lib.csdn.net/base/scala/structure http://hongjiang.info/scala/ http://blog.csdn.ne ...