题目链接:http://ac.jobdu.com/problem.php?pid=1006

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

参考代码:

//
//  1006 ZOJ问题.cpp
//  Jobdu
//
//  Created by PengFei_Zheng on 28/04/2017.
//  Copyright © 2017 PengFei_Zheng. All rights reserved.
//
 
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
#define MAX_SIZE 1001
 
using namespace std;
 
string str;
 
bool judge(){
    int idxZ = -1 ;
    int idxJ = -1 ;
    bool zoj = true;
    int len = (int)str.size();
    for(int i = 0 ; i < len ; i++){
        if(str[i]=='z' && idxZ == -1){
            idxZ = i;
        }
        else if(str[i]=='j' && idxJ == -1){
            idxJ = i;
        }
        else if(str[i]!='o'){
            zoj = false;
        }
    }
    int a = idxZ;
    int b = idxJ - idxZ -1;
    int c = len - 1 - idxJ;
    if(zoj && idxZ != -1 && idxJ != -1 && (idxZ +1 < idxJ) && a*b==c){
        return true;
    }
    else return false;
}
int main(){
    while(cin>>str){
        if(judge()){
            printf("Accepted\n");
        }
        else{
            printf("Wrong Answer\n");
        }
    }
}
/**************************************************************
    Problem: 1006
    User: zpfbuaa
    Language: C++
    Result: Accepted
    Time:60 ms
    Memory:1520 kb
****************************************************************/

 

相关文章:

  • 2022-02-12
  • 2022-02-16
  • 2022-02-12
  • 2021-10-04
  • 2021-09-21
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2021-12-10
  • 2021-05-24
  • 2021-09-14
  • 2021-11-25
  • 2021-11-30
  • 2021-10-05
  • 2021-05-29
相关资源
相似解决方案