A

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
typedef long long ll;

int main()
{
    int q;
    cin>>q;
    ll a,b,c,d;
    while(q--)
    {
        cin>>a>>b>>c>>d;
        if(a!=c)
        cout<<a<<" "<<c<<endl;
        else cout<<a<<" "<<d<<endl;
    }
    return 0;
}

b

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
typedef long long ll;
int n;
int a[200];
int b[10005];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    sort(a,a+n);
    ll aa=a[n-1];
    int bb=0;
    cout<<aa<<" ";
    for(int i=1;i*i<=aa;i++)
    {
        if(aa%i==0)
        {
            b[i]--;
            if(aa/i!=i)
            {
                b[aa/i]--;
            }
        }
    }
    for(int i=1;i<=10000;i++)
    {
        if(b[i]) bb=max(bb,i);
    }
    cout<<bb<<endl;
    return 0;
}
View Code

c

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
typedef long long ll;
#define INF 0x3f3f3f3f
int n;
string s;
string ss[7];
int minn=INF;
int main()
{
    ss[1]="RGB";
    ss[2]="RBG";
    ss[3]="GBR";
    ss[4]="GRB";
    ss[5]="BRG";
    ss[6]="BGR";
    cin>>n;
    cin>>s;
    int tt=1;
    for(int j=1;j<=6;j++){
            int tmp=0;
     for(int i=0;i<s.size();i++)
     {
        int t=i%3;
        if(ss[j][t]!=s[i]) tmp++;
     }
      if(tmp<minn)
      {
          tt=j;
          minn=tmp;
      }
    }
    cout<<minn<<endl;
    for(int i=0;i<s.size();i++)
    {
        int t=i%3;
        cout<<ss[tt][t];
    }
    cout<<endl;
    return 0;
}
View Code

d

#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> PII;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
//head
#define INF 0x3f3f3f3f
int n;
string s;
int main()
{
    cin>>n;
    cin>>s;
    int minn=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==s[i+1])
        {
            if(s[i]=='R')
            {
                if(s[i+2]=='B') s[i+1]='G';
                else if(s[i+2]=='G') s[i+1]='B';
                else s[i+1]='G';
            }
            else if(s[i]=='B')
            {
                if(s[i+2]=='B') s[i+1]='R';
                else if(s[i+2]=='G') s[i+1]='R';
                else s[i+1]='G';
            }
            else {
                if(s[i+2]=='B') s[i+1]='R';
                else if(s[i+2]=='G') s[i+1]='R';
                else s[i+1]='B';
            }
            minn++;
        }
    }
    cout<<minn<<endl;
    cout<<s<<endl;
    return 0;
}
View Code

e1

#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[305];
int b[305];
vector<int>v;
struct node
{
    int l,r;
}s[305];
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>s[i].l>>s[i].r;
        --s[i].l;
        --s[i].r;
    }
        int minn=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i>=s[j].l&&i<=s[j].r)
            {
                for(int k=s[j].l;k<=s[j].r;k++)
                    a[k]-=1;
            }
        }
        sort(a,a+n);
        if(minn<a[n-1]-a[0])
        {
            v.clear();
            minn=a[n-1]-a[0];
            for(int j=1;j<=m;j++)
            {
                if(i>=s[j].l&&i<=s[j].r)
                    v.push_back(j);
            }
        }
        for(int j=0;j<n;j++)
            a[j]=b[j];
    }
    cout<<minn<<endl;
    cout<<v.size()<<endl;
    for(int i=0;i<v.size();i++)
        cout<<v[i]<<" ";
    cout<<endl;
}

 

posted on 2019-01-31 14:15  海苔  阅读(112)  评论(0编辑  收藏  举报