【AtCoder】ARC091
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的更多相关文章
- 【AtCoder】ARC092 D - Two Sequences
[题目]AtCoder Regular Contest 092 D - Two Sequences [题意]给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1<=i,j<=n ...
- 【Atcoder】CODE FESTIVAL 2017 qual A D - Four Coloring
[题意]给定h,w,d,要求构造矩阵h*w满足任意两个曼哈顿距离为d的点都不同色,染四色. [算法]结论+矩阵变换 [题解] 曼哈顿距离是一个立着的正方形,不方便处理.d=|xi-xj|+|yi-yj ...
- 【AtCoder】ARC 081 E - Don't Be a Subsequence
[题意]给定长度为n(<=2*10^5)的字符串,求最短的字典序最小的非子序列字符串. http://arc081.contest.atcoder.jp/tasks/arc081_c [算法]字 ...
- 【AtCoder】AGC022 F - Leftmost Ball 计数DP
[题目]F - Leftmost Ball [题意]给定n种颜色的球各k个,每次以任意顺序排列所有球并将每种颜色最左端的球染成颜色0,求有多少种不同的颜色排列.n,k<=2000. [算法]计数 ...
- 【AtCoder】AGC005 F - Many Easy Problems 排列组合+NTT
[题目]F - Many Easy Problems [题意]给定n个点的树,定义S为大小为k的点集,则f(S)为最小的包含点集S的连通块大小,求k=1~n时的所有点集f(S)的和取模92484403 ...
- 【AtCoder】ARC067 F - Yakiniku Restaurants 单调栈+矩阵差分
[题目]F - Yakiniku Restaurants [题意]给定n和m,有n个饭店和m张票,给出Ai表示从饭店i到i+1的距离,给出矩阵B(i,j)表示在第i家饭店使用票j的收益,求任选起点和终 ...
- 【AtCoder】ARC095 E - Symmetric Grid 模拟
[题目]E - Symmetric Grid [题意]给定n*m的小写字母矩阵,求是否能通过若干行互换和列互换使得矩阵中心对称.n,m<=12. [算法]模拟 [题解]首先行列操作独立,如果已确 ...
- 【Atcoder】AGC022 C - Remainder Game 搜索
[题目]C - Remainder Game [题意]给定n个数字的序列A,每次可以选择一个数字k并选择一些数字对k取模,花费2^k的代价.要求最终变成序列B,求最小代价或无解.n<=50,0& ...
- 【Atcoder】AGC 020 B - Ice Rink Game 递推
[题意]n个人进行游戏,每轮只保留最大的a[i]倍数的人,最后一轮过后剩余2人,求最小和最大的n,或-1.n<=10^5. [算法]递推||二分 [题解]令L(i),R(i)表示第i轮过后的最小 ...
随机推荐
- File类里的静态字段
我们都知道windows操作系统和Linux操作系统中的路径分隔符是不一样的,当我们直接使用绝对路径的时候,程序会报错误:No such file or diretory”的异常 File类有几个类似 ...
- bzoj 2275: [Coci2010]HRPA
据说叫斐波那契博弈. 先手最少取的石子数是把n用斐波那契数列拆分后最小的数. 原题+证明: http://blog.csdn.net/acm_cxlove/article/details/783501 ...
- C# 获取IIS站点及虚拟目录信息
using System; using System.DirectoryServices; using System.Collections.Generic; using System.Text; n ...
- JS控制form表单action去向
http://blog.csdn.net/w709854369/article/details/6261624 不知道大家遇没遇到这种情况,当我们提交一个表单的时候,可能因为相关的参数不同而需提交给不 ...
- Hadoop生态圈-Flume的组件之sink处理器
Hadoop生态圈-Flume的组件之sink处理器 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一. 二.
- bzoj千题计划269:bzoj2655: calc (拉格朗日插值)
http://www.lydsy.com/JudgeOnline/problem.php?id=2655 f[i][j] 表示[1,i]里选严格递增的j个数,序列值之和 那么ans=f[A][n] * ...
- 第一次使用 markdown 写博客
Web前端 js 框架(四选一) 有可能的话,学 Vue.js ,React.js ,Angular.js,Awrelia css 学习 Sass 学会 css 的可编程 HTML5 详细语法 Nod ...
- Java面试题系列(二)Java内存模型
在进行Java编程时,我们通常需要通过new创建一个对象的实例.就比如有一个People的类,那么创建一个People的实例:People w_people = new People(); 此时,ne ...
- lemon spj无效编译器解决方法
反正我是被坑了很久,心里增的敲难过呀! 我曾经无数次的想把它解决掉: 啊啊啊啊啊啊! 什么嘛!什么嘛! 这个空白的框框里到底要填什么嘛!!! 你已经是一个成熟的lemon了,就不能自动识别给个选项吗! ...
- Linux Timer定时器【转】
转自:https://www.jianshu.com/p/66b3c75cae81 timerfd为Linux为用户程序提供的定时器接口,该接口基于文件描述符,通过文件描述符的可读事件进行超时通知,且 ...