题目1006:ZOJ问题(递推规律)
2024-10-15 01:56:39
题目链接: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 = - ;
int idxJ = - ;
bool zoj = true;
int len = (int)str.size();
for(int i = ; i < len ; i++){
if(str[i]=='z' && idxZ == -){
idxZ = i;
}
else if(str[i]=='j' && idxJ == -){
idxJ = i;
}
else if(str[i]!='o'){
zoj = false;
}
}
int a = idxZ;
int b = idxJ - idxZ -;
int c = len - - idxJ;
if(zoj && idxZ != - && idxJ != - && (idxZ + < 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
****************************************************************/
最新文章
- WiX Toolset 教程索引页
- MVC中RenderBody的工作原理
- ajax+div 代替iframe 学习尝试
- Error: Bootstrap&#39;s JavaScript requires jQuery错误
- Anliven - 有效阅读的方法
- Ruby中 使用Builder Xml Markup 操作XML
- Nginx + PHP 缓存详解
- Context Menu on DataGrid
- LeetCode 3
- JavaScript/jQuery选择器简介
- bootstrap_下拉菜单+头部
- Spring-MVC请求参数值和向页面传值
- markdown箭头的处理
- java获取真实的IP地址工具类
- ASP MD5
- SpringSecurity实现图形验证码功能
- Qt5 中文乱码问题
- Hadoop基础-Hdfs各个组件的运行原理介绍
- zabbix3.0.4 配置邮件报警
- 9-centos定时任务-不起作用- 没指明路径!!!