AtCoder Beginner Contest 175----A.Rainy Season,B.Making Triangle

旧人旧事更值得怀念,或悲或喜每个人身上都承载着某一段时光,但是我会永远清澈永远疯狂永远浪漫。没有人能回到过去重新活过,但你我都可以从现在开始,决定我们未来的模样。
                                                                                                                                                                           ----喻言

 

题解:连续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;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值