链接:https://ac.nowcoder.com/acm/contest/992/G
来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
这道题你只需要呆萌呆萌的把下面的代码交上去就行了,我书读的多,不会骗你的,我发4。
#include<stdio.h> #include<string.h> int main() { char ch[100007]; int len,ans=0; scanf("%s",ch); len=strlen(ch); for(int i=0;i<len;i++) for(int j=i+1;j<len;j++) for(int k=j+1;k<len;k++) if(ch[i]=='O'&&ch[j]=='R'&&ch[k]=='Z') ans++; printf("%d\n",ans); }
输入描述:
输入一行一个仅包含'O','R'和'Z'三种字符的字符串s。( 0 < |s| <= 100000 )
输出描述:
一行一个整数表示代码中ans的值。
示例1
输入
复制
ORZORZ
输出
复制
4
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <string.h>
#include <string>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
int main(){
string s;
cin>>s;
ll numO=0,numR=0,numZ=0;
for(int i=0;i<s.length();i++){
if(s[i] == 'O'){
numO++;
}
else if(s[i] == 'R'){
numR += numO;
}
else if(s[i] == 'Z'){
numZ += numR;
}
}
cout<<numZ<<endl;
return 0;
}