旧人旧事更值得怀念,或悲或喜每个人身上都承载着某一段时光,但是我会永远清澈永远疯狂永远浪漫。没有人能回到过去重新活过,但你我都可以从现在开始,决定我们未来的模样。
----喻言
题解:连续R的个数
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <complex>
#include <iomanip>
#include <numeric>
#include<unordered_set>
#include <climits>//INT_100010n
#include <regex>
#include<deque>
//#include<bits/stdc++.h>
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926
#define LL unsigned int
#define wc 1e-18
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
typedef long long ll;
string s;
int ct=0;
int main(){
cin>>s;
for(int i=0;i<3;i++){
if(s[i]=='R')
ct++;
}
if(ct==0)
cout<<0<<endl;
else if(ct==1)
cout<<1<<endl;
else if(ct==2){
if(s[0]==s[1]||s[1]==s[2])
cout<<2<<endl;
else
cout<<1<<endl;
}
else if(ct==3)
cout<<3<<endl;
return 0;
}
题解:找到给出的序列中能构成三角形的组数,暴力枚举即可
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <complex>
#include <iomanip>
#include <numeric>
#include<unordered_set>
#include <climits>//INT_100010n
#include <regex>
#include<deque>
//#include<bits/stdc++.h>
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926
#define LL unsigned int
#define wc 1e-18
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
typedef long long ll;
int N,L[110],ct;
int main(){
cin>>N;
for(int i=0;i<N;i++)
cin>>L[i];
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
for(int k=j+1;k<N;k++){
if(L[i]!=L[j]&&L[i]!=L[k]&&L[j]!=L[k])
if(L[i]+L[j]>L[k]&&L[i]+L[k]>L[j]&&L[j]+L[k]>L[i])
ct++;
}
}
}
cout<<ct<<endl;
return 0;
}