ZeptoLab Code Rush 2015 A. King of Thieves

题目大意:

  就是说,对于一个起点,使得从这个起点开始,每次间隔相同的格子后,所经过的地方都是‘*’

解题思路:

  直接暴力,枚举起点+枚举公差

代码:

 1     # include<cstdio>
 2     # include<iostream>
 3
 4     using namespace std;
 5
 6     # define MAX 123
 7
 8     char s[MAX];
 9     int a[MAX];
10
11     int main(void)
12     {
13         int n;
14         scanf("%d",&n);
15         scanf("%s",s+1);
16         int flag = 0;
17         for ( int i = 1;i <= n;i++ )
18         {
19             for ( int j = 1;j <= 100;j++ )
20             {
21                 if ( s[i]==‘*‘&&s[i+j]==‘*‘&&s[i+2*j]==‘*‘&&s[i+3*j]==‘*‘&&s[i+4*j]==‘*‘ )
22                 {
23                     flag = 1;
24                     break;
25                 }
26             }
27             if ( flag )
28                 break;
29         }
30         if ( flag )
31             cout<<"yes"<<endl;
32         else
33             cout<<"no"<<endl;
34
35
36
37         return 0;
38     }
时间: 2024-10-25 07:49:17

ZeptoLab Code Rush 2015 A. King of Thieves的相关文章

ZeptoLab Code Rush 2015 A. King of Thieves 暴力

A. King of Thieves Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/526/problem/A Description In this problem you will meet the simplified model of game King of Thieves. In a new ZeptoLab game called "King of Thieves" y

Codeforces ZeptoLab Code Rush 2015

比赛链接:http://codeforces.com/contest/526/ A. King of Thieves time limit per test:1 second memory limit per test:256 megabytes In this problem you will meet the simplified model of game King of Thieves. In a new ZeptoLab game called "King of Thieves&quo

【codeforces ZeptoLab Code Rush 2015】ABCD题解

A. King of Thieves time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output In this problem you will meet the simplified model of game King of Thieves. In a new ZeptoLab game called "King of Thieves&quo

ZeptoLab Code Rush 2015

A 题意:给出一串由.*组成的字符串,如果有等间距的五个及五个以上的*存在,则输出yes 直接枚举就可以了 看题一定要仔细啊,做的时候看成必须有五个等间距的".*"才可以跳跃= = 然后就这样写居然过了预测= =后来果然被hack了 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include <cmath> 5 #include<stack> 6

ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS

B. Om Nom and Dark Park Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/526/problem/B Description Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living a

ZeptoLab Code Rush 2015 C. Om Nom and Candies 暴力

C. Om Nom and Candies Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/526/problem/C Description A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him

ZeptoLab Code Rush 2015 B. Om Nom and Dark Park

1.题目描述:点击打开链接 2.解题思路:比赛时候这道题没有做出来,第二天早晨补题时才发现就是简单的DFS应用.题目要求出最少需要增加几盏路灯.假设我们已经知道了root的左子结点一共有suml盏路灯,右子结点一共有sumr盏路灯,那么比较一下d[lson(root)]+suml和d[rson(root)]+sumr的大小即可.此时需要增加的路灯数量就是两者差的绝对值.同时返回较大的数即得到root的总路灯数量. 3.代码: #define _CRT_SECURE_NO_WARNINGS #in

ZeptoLab Code Rush 2015 C. Om Nom and Candies

1.题目描述:点击打开链接 2.解题思路:本题是无限背包问题,根据重量的约束关系,直接暴力搜索. 3.代码: #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<algorithm> #include<string> #include<sstream> #include<set> #include<vector> #include<stack> #incl

【codeforces】ZeptoLab Code Rush 2015 E 跳跃表?

题意就是给n个数,围成一圈,就是1和n是相邻的,然后给一个数b,总和不超过b的一段连续的数可以组成一组,问最少可以将n个数分成几组. 可以将n个数后面再接n个数,就变成n+n个数,然后以每个数为开头的组最远能到哪也是很容易求的,O(n)维护个指针可以处理.把远的位置视为跳一步能到的吧,这样问题就转化为1到n中的第i个数至少到第n+i个数要跳多少次.这个如果是一般图的话,就是类似树上求k步的祖先在哪,可以用倍增法,n*log(n).但是这题图比较特殊,i<j的话,i跳到的下一点位置不会超过j跳到的