A. Alena's Schedule

间隔0长度为1被记录  1被记录  其余不记录

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main()
{
int t;
cin>>t;
int pre = ;
int a = ,ans= ;
bool mk = false;
while(t--)
{
cin>>a;
if(a)
{
if(pre<)
ans+=pre;
pre=;
ans+=;
mk=true;
}
else{
if(mk)
{
pre++;
}
}
}
cout<<ans<<endl;
return ;
}

AC代码

B. Laurenty and Shop

前缀后缀枚举转折点。

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <climits>
using namespace std;
int a[],b[];
int main()
{
int t;
cin>>t;
int x;
for(int i=;i<t;i++) // 0 1 2 3
{
cin>>x;
a[i] = a[i-] + x;
}
for(int i=;i<t;i++) // 0 1 2 3
{
cin>>x;
b[i] = b[i-] + x;
}
vector<int>v;
for(int i=;i<t;i++)
{
cin>>x;
v.push_back(a[i]+b[t-]-b[i]+x);
}
sort(v.begin(),v.end());
cout<<v[]+v[]<<endl;
return ;
}

AC代码

C. Gennady the Dentist

读不懂  模拟题

D. Phillip and Trains

每次向右走一格,所以我们只要确定他活过m轮,就一定到达终点。//

判断车的位置   当前位置加2×t   车的位置不容易改变所以我们把自己加上2×t相当于车往左走了2×t  判断是否合法即可

比赛的时候vis标记位置放错....还是太菜了呢

就是太菜,不想找什么英语差的借口了

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
bool vis[][];
char ch[][];
int n,m;
typedef pair<int,int> pii;
bool check(int x,int y,int dir,int t,vector<pii>& now)
{
int nx = dir+x;
int ny = y+;
if(nx<||nx>=n||ny<||ny>=m||vis[nx][ny]) return false;
int a,b,c;
a = (y+*t+);
b = (a+);
c = (b+);
if(dir)
{
if((a<m&&ch[x][a]!='.')) return false;
}
if((a<m&&ch[nx][a]!='.')||(b<m&&ch[nx][b]!='.')||(c<m&&ch[nx][c]!='.')) return false;
now.push_back(make_pair(nx,ny));
vis[nx][ny] = true;
return true;
} bool bfs(int x,int y)//shijiweizhi
{
vector<pii>now,nxt;
now.push_back(make_pair(x,y));
int time = ;
vis[x][y] = true;
while(now.size())
{
if(time>=m) break;
for(int i=;i<now.size();i++)
{
//printf("%d %d %d",time,now[i].first,now[i].second);
for(int j=-;j<=;j++)
{
check(now[i].first,now[i].second,j,time,nxt);
}
}
swap(now,nxt);
nxt.clear();
time++;
}
return time>=m;
}
int main()
{
int t;
cin>>t;
while(t--)
{
memset(vis,,sizeof(vis));
memset(ch,,sizeof(ch));
int k;
scanf("%d%d",&m,&k);
n = ;
int sx,sy;
for(int i=;i<n;i++)
{
scanf("%s",ch[i]);
for(int j=;j<m;j++)
{
if(ch[i][j]=='s')
{
ch[i][j] = '.';
sx = i;
sy = j;
}
}
}
//cout<<sx<<sy<<endl;
if(bfs(sx,sy)) puts("YES");
else puts("NO");
}
return ;
}

AC代码

E. Alice, Bob, Oranges and Apples

每个人操作的次数就是GCD的过程

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string.h>
#include <cctype>
#include <climits>
using namespace std;
typedef long long ll;
char ch = 'A';
bool mk;
ll gcd(ll a,ll b)
{
if(b==) return a;
ll val = a/b;
if(val)
{
if(a%b==) val--;
if(val)
{
cout<<val<<char(ch+mk);
mk = !mk;
}
} return gcd(b,a%b);
}
int main()
{
ll x,y;
cin>>x>>y;
mk = x<y;
if(__gcd(x,y)!=)
{
printf("Impossible");
}
else{
gcd(x,y);
}
return ;
}

AC代码

Codeforces Round #325 垫底纪念的更多相关文章

  1. Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid

    F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  2. Codeforces Round #325 (Div. 2) D. Phillip and Trains BFS

    D. Phillip and Trains Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/ ...

  3. Codeforces Round #325 (Div. 2) C. Gennady the Dentist 暴力

    C. Gennady the Dentist Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586 ...

  4. Codeforces Round #325 (Div. 2) A. Alena's Schedule 水题

    A. Alena's Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/pr ...

  5. Codeforces Round #325 (Div. 2) B. Laurenty and Shop 前缀和

    B. Laurenty and Shop Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/p ...

  6. Codeforces Round #325 (Div. 2) Phillip and Trains dp

    原题连接:http://codeforces.com/contest/586/problem/D 题意: 就大家都玩过地铁奔跑这个游戏(我没玩过),然后给你个当前的地铁的状况,让你判断人是否能够出去. ...

  7. Codeforces Round #325 (Div. 2) Laurenty and Shop 模拟

    原题链接:http://codeforces.com/contest/586/problem/B 题意: 大概就是给你一个两行的路,让你寻找一个来回的最短路,并且不能走重复的路. 题解: 就枚举上下选 ...

  8. Codeforces Round #325 (Div. 2) Alena's Schedule 模拟

    原题链接:http://codeforces.com/contest/586/problem/A 题意: 大概就是给你个序列..瞎比让你统计统计什么长度 题解: 就瞎比搞搞就好 代码: #includ ...

  9. Codeforces Round #325 (Div. 2) D bfs

    D. Phillip and Trains time limit per test 1 second memory limit per test 256 megabytes input standar ...

随机推荐

  1. Maven学习8-使用Maven构建多模块项目

    在平时的Javaweb项目开发中为了便于后期的维护,我们一般会进行分层开发,最常见的就是分为domain(域模型层).dao(数据库访问 层).service(业务逻辑层).web(表现层),这样分层 ...

  2. SQL总结(二)连表查询

    ---恢复内容开始--- SQL总结(二)连表查询 连接查询包括合并.内连接.外连接和交叉连接,如果涉及多表查询,了解这些连接的特点很重要. 只有真正了解它们之间的区别,才能正确使用. 1.Union ...

  3. 【日期-时间】Java中Calendar的使用

    主要介绍了Calendar类的使用 输出 * 时间格式化 * 当前时间:2016-12-02 16:46:27.079 * * 转换:String-->Date-->Calendar * ...

  4. ERROR 1130 (HY000):Host'localhost'解决方法

    http://www.2cto.com/database/201211/169504.html ERROR 1130 (HY000):Host'localhost'解决方法   ERROR 1130 ...

  5. [系统开发] Django Admin上传图片简单校验

    我的 models里有个ImageField字段,用来保存用户头像,希望通过Django Admin上传时校验头像大小,如果太大就报错,并且不保存. 网上有不少方法,有的通过第三方软件实现,有的通过自 ...

  6. ruby md5加签验签方法

    # md5签名def md5_sign(data,key) return OpenSSL::Digest::MD5.hexdigest(data+key)end # md5验签def md5_veri ...

  7. 【AT91SAM3S】串口UART初始化及收发数据

    SAM3S中的UART串口是一个两线异步收发器.这个串口能用来通信或者跟踪.有两个DMA通道与UART串口关联,可通过使用DMA处理串口传输以节省CPU时间. SAM3S4C中有两个UART.与外设引 ...

  8. 原生+jquery 实现好看滚动条。

    //原生 <!doctype html> <html> <head> <meta charset="utf-8"> <titl ...

  9. 怎么取消 Windows Server 2012 r2 RDP 限制每个用户只能进行一个会话(转)

    在 Windows Server 2008 / 2008 R2 上,如果希望多个远程用户使用同一个账号同时访问服务器的 Remote Desktop(RDP),只需通过管理工具-远程桌面下的“远程桌面 ...

  10. JSTL+MyEclipse8.5+Tomcat配置

    使用JSTL的时候需要配置,即导入stdandard.jar和jstl.jar包,并在web.xml下对jstl进行配置.下面是使用步骤: 1. 解压jakarta-taglibs-standard- ...