A.うるう年

题意:判断闰年

做法:。。

#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
template<typename T> inline void read(T &x)
{
T data=0,w=1;
char ch=0;
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')w=-1,ch=getchar();
while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
int n;read(n);
if(n%4!=0)puts("NO");
else
{
if(n%100==0&&n%400!=0)puts("NO");
else puts("YES");
}
return 0;
}

B.リモコン

题意:找到在给定日期之后的一个日期,使得年/月/日是整数(/是除法的意思)

做法:枚举

#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
int a,b,c,mh[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
template<typename T> inline void read(T &x)
{
T data=0,w=1;
char ch=0;
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')w=-1,ch=getchar();
while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline bool check(int x)
{
if(x%4!=0)return false;
else
{
if(x%100==0&&x%400!=0)return false;
return true;
}
}
inline void print(int y,int m,int d)
{
printf("%d/",y);
if(m<10)putchar('0');
printf("%d/",m);
if(d<10)putchar('0');
printf("%d\n",d);
}
int main()
{
read(a);read(b);read(c);
REP(i,a,3000)REP(j,i==a?b:1,12)
{
int lt=mh[j];
if(j==2&&check(i))lt=29;
REP(k,i==a&&j==b?c:1,lt)if(i%(j*k)==0)
{
print(i,j,k);
return 0;
}
}
return 0;
}

C.パズルのお手伝い

题意:给一个只包含A, B, X, Y的字符串,每次操作可以减去一个字符或者一个你自己规定的两个由两个字符组成的组合,问将字符串清空的最小操作数

做法:枚举所有组合,取最小值就好了

#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=1000+10,inf=0x3f3f3f3f;
int n,ans=inf;
char s[MAXN];
template<typename T> inline void read(T &x)
{
T data=0,w=1;
char ch=0;
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')w=-1,ch=getchar();
while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
read(n);scanf("%s",s+1);
REP(i,1,n)
if(s[i]=='A')s[i]=1;
else if(s[i]=='B')s[i]=2;
else if(s[i]=='X')s[i]=3;
else s[i]=4;
REP(i,1,4)REP(j,1,4)REP(k,1,4)REP(p,1,4)
{
int res=n;
REP(l,1,n)if((s[l-1]==i&&s[l]==j)||(s[l-1]==k&&s[l]==p))res--,++l;
chkmin(ans,res);
}
write(ans,'\n');
return 0;
}

D.レースゲーム

题意:一个 \(n*m\) 的棋盘,其中第 \(1\) 列和第 \(m\) 列是双方的阵营。棋盘上现在有一些双方的棋子,剩下的位置是空地。棋子只能往对方的方向走(即一个向左,一个向右),可以吃掉对方的棋子。最先将自己棋子移动到对方阵营里的人获胜。给定一个棋盘局面,问谁必胜

做法:首先特判有没有没有阻碍直接可以到对面阵营的。然后由于双方足够聪明,所以每种局面都可以转化成一种无论谁再走一步就会吃子的局面。而谁从原来的局面变成新局面的步数更多谁就必胜,因为步数少的那一个人必定会先走出被吃子的那一步,然后引发连锁反应,使自己所有子都被吃

#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
#define REP(a,b,c) for(register int a=(b),a##end=(c);a<=a##end;++a)
#define DEP(a,b,c) for(register int a=(b),a##end=(c);a>=a##end;--a)
const int MAXN=2000+10,inf=0x3f3f3f3f;
int n,m;
ll vL,vR;
char G[MAXN][MAXN];
std::vector< std::pair<int,int> > ext;
template<typename T> inline void read(T &x)
{
T data=0,w=1;
char ch=0;
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')w=-1,ch=getchar();
while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline void init()
{
int mL=inf,mR=inf;
REP(i,1,n)
{
REP(j,1,m)
{
if(G[i][j]=='x')chkmin(mR,j-1);
if(G[i][j]!='.')break;
}
DEP(j,m,1)
{
if(G[i][j]=='o')chkmin(mL,m-j);
if(G[i][j]!='.')break;
}
}
if(mL!=inf||mR!=inf)puts(mL<=mR?"o":"x"),exit(0);
}
int main()
{
read(n);read(m);
REP(i,1,n)scanf("%s",G[i]+1);
init();
REP(i,1,n)
{
int j=1;
while(j<=m)
{
while(j<=m&&G[i][j]=='.')++j;
int L=j,Lr,Lp,Ls=0;
while(j<=m&&G[i][j]!='x')++j;
while(j<=m&&G[i][j]!='o')++j;j--;
int R=j,Rl,Rp,Rs=0;
if(L>R)break;
DEP(k,R,L)if(G[i][k]=='o'){Lr=k;break;}
REP(k,L,R)if(G[i][k]=='x'){Rl=k;break;}
Lp=Lr,Rp=Rl;
while(Rp-Lp-1>2)Lp++,Rp--;
int mk=(Rp-Lp-1==2);
DEP(k,Lr,L)if(G[i][k]=='o')vL+=Lp-k,Lp--,Ls++;
REP(k,Rl,R)if(G[i][k]=='x')vR+=k-Rp,Rp++,Rs++;
if(mk)ext.push_back(std::make_pair(Ls+Rs,Ls));
++j;
}
}
std::sort(ext.begin(),ext.end());
DEP(i,ext.size()-1,0)
if((ext.size()-i-1)%2)vR+=ext[i].first-ext[i].second;
else vL+=ext[i].second;
puts(vL>vR?"o":"x");
return 0;
}

【刷题】AtCoder Regular Contest 002的更多相关文章

  1. AtCoder Regular Contest 092

    AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...

  2. AtCoder Regular Contest 102

    AtCoder Regular Contest 102 C - Triangular Relationship 题意: 给出n,k求有多少个不大于n的三元组,使其中两两数字的和都是k的倍数,数字可以重 ...

  3. AtCoder Regular Contest 096

    AtCoder Regular Contest 096 C - Many Medians 题意: 有A,B两种匹萨和三种购买方案,买一个A,买一个B,买半个A和半个B,花费分别为a,b,c. 求买X个 ...

  4. AtCoder Regular Contest 097

    AtCoder Regular Contest 097 C - K-th Substring 题意: 求一个长度小于等于5000的字符串的第K小子串,相同子串算一个. K<=5. 分析: 一眼看 ...

  5. AtCoder Regular Contest 098

    AtCoder Regular Contest 098 C - Attention 题意 给定一个只包含"E","W"字符串,可以花一的花费使他们互相转换.选定 ...

  6. Atcoder regular Contest 073(C - Sentou)

    Atcoder regular Contest 073(C - Sentou) 传送门 每个人对开关的影响区间为a[i]--a[i]+t,因此此题即为将所有区间离散化后求所有独立区间的长度和 #inc ...

  7. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  8. AtCoder Regular Contest 094 (ARC094) CDE题解

    原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...

  9. AtCoder Grand Contest 002

    AtCoder Grand Contest 002 A - Range Product 翻译 告诉你\(a,b\),求\(\prod_{i=a}^b i\)是正数还是负数还是零. 题解 什么鬼玩意. ...

随机推荐

  1. odoo之页面跳转

    击备注时,会由备注id带出他的内容 customer.requirement这是备注内容表 def sale_requirements_change(self, cr, uid, ids, requi ...

  2. ASP.NET Core 使用外部登陆提供程序登陆的流程,以及身份认证的流程 (转载)

    阅读目录 在Asp.Net Core 中使用外部登陆(google.微博...) 中间件管道 The Authentication Middleware The Challenge 与认证中间件进行交 ...

  3. 使用gulp和bable实现实时编译ES6代码

    这篇文章最初发表在我自己折腾的博客站点上:使用gulp和bable实现实时编译ES6代码,该博客用了一位前辈开源的源码,基于thinkjs和vuejs开发,欢迎大家来逛逛. 问题描述> 项目开发 ...

  4. 把DataTable转换为List<T>

    前一篇有学习过<把List<T>转换为DataTable>http://www.cnblogs.com/insus/p/8043173.html 那此篇,将是学习反向,把Dat ...

  5. [Oracle]获得PDB相关的xml 文件

    问题:客户进行了PDB的克隆之后,发现启动时出现: ORA-44777: Pluggable database service cannot be started. 分析手段: 为了获得PDB的相关信 ...

  6. 如何使用串口来给STM32下载程序

    前言 第一次学习STM32的时候,不知道有调试器这个东西,所以一直是通过串口来给STM32下载程序,下载速度也还算可以,一般是几秒钟完成.后来用了调试器,可以直接在Keil环境下进行下载,而且还可以进 ...

  7. ML.NET 示例:多类分类之问题分类

    写在前面 准备近期将微软的machinelearning-samples翻译成中文,水平有限,如有错漏,请大家多多指正. 如果有朋友对此感兴趣,可以加入我:https://github.com/fei ...

  8. linux下监控某个目录是否被更改

    需求:对一个目录(比如/data/test)进行监控,当这个目录下文件或子目录出现变动(如修改.创建.删除.更名等操作)时,就发送邮件!针对上面的需求,编写shell脚本如下: [root@cento ...

  9. [linux] VirtualBox复制虚拟机

    环境: Oracle VM VirtualBox 5.0.20 CentOS-6.7-x86_64-minimal.iso 1.复制虚拟机 -->右击休眠状态模板虚拟机,选择复制 -->填 ...

  10. C_数据结构_链式二叉树

    # include <stdio.h> # include <malloc.h> struct BTNode { int data; struct BTNode * pLchi ...