B.Baby Bites---Gym101933(简单模拟)

Baby Bites

Time Limit: 1 Sec Memory Limit: 128 Mb

练习链接https://codeforces.com/gym/101933/problem/B
Description
Arild just turned 1 year old, and is currently learning how to count. His favorite thing to count is how many mouthfuls he has in a meal: every time he gets a bite, he will count it by saying the number out loud.

Unfortunately, talking while having a mouthful sometimes causes Arild to mumble incomprehensibly, making it hard to know how far he has counted. Sometimes you even suspect he loses his count! You decide to write a program to determine whether Arild’s counting makes sense or not.

Input
The first line of input contains an integer n (1 ≤ n ≤ 1 000), the number of bites Arild receives. Then second line contains n space-separated words spoken by Arild, the i’th of which is either a non-negative integer ai (0 ≤ ai ≤ 10 000​) or the string “mumble”.

Output
If Arild’s counting might make sense, print the string “makes sense”. Otherwise, print the string “something is fishy”.

Sample Input
5
1 2 3 mumble 5


8
1 2 3 mumble mumble 7 mumble 8


3
mumble mumble mumble

Sample Output
makes sense


something is fishy


makes sense


简单模拟,没什么好说的。。。
题目大意是这样的,判断一个数列是否是连续的,中间有模糊的数。如果是连续的输出makes sense否则输出something is fishy

#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#define RI register int
using namespace std;
# define IOS ios::sync_with_stdio(false)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
#define lowbit(x) (x&-x)  
string str;
int change(string s){
    int len=s.size();
    int ret=0;
    for(int i=0;i<len;i++){
        ret=ret*10+str[i]-'0';
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int flag=0;
    for(int i=1;i<=n;i++){     //注意是从一开始的
        cin>>str;
        if(str[0]>='0'&&str[0]<='9'){
            int num=change(str);
            if(num!=i) flag=1;
        }
    }
    if(flag) cout<<"something is fishy"<<endl;
    else cout<<"makes sense"<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值