前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >2020ICPC·小米 网络选拔赛热身赛

2020ICPC·小米 网络选拔赛热身赛

作者头像
dejavu1zz
发布2020-11-12 11:06:45
2660
发布2020-11-12 11:06:45
举报

A

描述
提议描述
提议描述
AC代码
代码语言:javascript
复制
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <set>
#include <stack>
#include <iomanip>
#define x first
#define y second
#define PB push_back
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define rep(x,l,u) for(ll x=l;x<u;x++)
#define rrep(x,l,u) for(ll x=l;x>=u;x--)
#define sz(x) x.size()
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define seteps(N) setprecision(N)
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<char,char> PCC;
typedef long long ll;
typedef pair<ll,ll> PLL;
typedef __int128 lll;
const int N=2*1010;
const int M=1e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const lll one=1;
ll f[N][N];
void solve(){
    double p=3.1415926;
    int n,m;
    while(cin>>n>>m){
        rep(i,0,n+m+1){
            rep(j,0,n+m+1){
                f[i][j]=0;
            }
        }
        f[0][0]=1;
        rep(i,0,n+m+1){
            rep(j,0,n+m+1){
                if(i>=1 && i-j<=n) f[i][j]=(f[i][j]+f[i-1][j])%mod;
                if(j>=1 && j-i<=m) f[i][j]=(f[i][j]+f[i][j-1])%mod;
            }
        }
        cout<<f[n+m][n+m]<<endl;
    }
}
int main(){
    IOS;
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    //int t;cin>>t;
    //while(t--)
    solve();
    return 0;
}

B

题意描述
题意描述
题意描述
AC代码
代码语言:javascript
复制
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <set>
#define x first
#define y second
#define PB push_back
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define rep(x,l,u) for(ll x=l;x<u;x++)
#define rrep(x,l,u) for(ll x=l;x>=u;x--)
#define sz(x) x.size()
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<char,char> PCC;
typedef long long ll;
typedef pair<ll,ll> PLL;
typedef __int128 lll;
const int N=2*1e5+10;
const int M=1e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const lll one=1;
int a[N];
void solve(){
    int n;
    cin>>n;
    rep(i,1,n+1) cin>>a[i];
    ll ans=0;
    map<int,int> used;
    rep(i,1,n+1){
        if(!used[a[i]]){
            ans+=(i*(n-i+1));
        }else{
            ans+=(n-i+1)*(i-used[a[i]]);
        }
        used[a[i]]=i;
    }
    cout<<ans<<endl;
}
int main(){
    IOS;
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    //int t;cin>>t;
    //while(t--)
    solve();
    return 0;
}

F

AC代码
代码语言:javascript
复制
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <set>
#define x first
#define y second
#define PB push_back
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define rep(x,l,u) for(ll x=l;x<u;x++)
#define rrep(x,l,u) for(ll x=l;x>=u;x--)
#define sz(x) x.size()
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<char,char> PCC;
typedef long long ll;
typedef pair<ll,ll> PLL;
typedef __int128 lll;
const int N=2*1e5+10;
const int M=1e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const lll one=1;
int a[N];
void solve(){
    ll a,b,x,y;
    while(cin>>x>>a>>y>>b){
        lll res1=one*x*b;
        lll res2=one*a*y;
        if(res1==res2) cout<<"="<<endl;
        else if(res1<res2) cout<<"<"<<endl;
        else cout<<">"<<endl;
    }
}
int main(){
    IOS;
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    //int t;cin>>t;
    //while(t--)
    solve();
    return 0;
}

G

题意描述
提议描述
提议描述
思路

使用一个字符串来储存删除过后的字符串序列,使用一个变量来表示删除后的字符串下标。每次符合条件时,变量都要向前移3位,模拟这个过程即可。

AC代码
代码语言:javascript
复制
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <set>
#include <stack>
#define x first
#define y second
#define PB push_back
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define rep(x,l,u) for(ll x=l;x<u;x++)
#define rrep(x,l,u) for(ll x=l;x>=u;x--)
#define sz(x) x.size()
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<char,char> PCC;
typedef long long ll;
typedef pair<ll,ll> PLL;
typedef __int128 lll;
const int N=2*1e5+10;
const int M=1e6+10;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const lll one=1;
void solve(){
    string s,v;
    cin>>s;
    v=s;
    int now=0,ans=0;
    rep(i,0,sz(s)){
        now++;
        v[now]=s[i];
        if(now>=3 && v[now]==v[now-1] && v[now-2]==v[now]){
            ans++;
            now-=3;
        }
    }
    cout<<ans<<endl;
}
int main(){
    IOS;
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    //int t;cin>>t;
    //while(t--)
    solve();
    return 0;
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-11-06 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • A
  • B
  • F
  • G
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档