• 题解


    ti

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    //freopen("T1.in","r",stdin);
    //freopen("T1.out","w",stdout);
    int n,m,a[10100],k=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
    {
    if(m>=a[i])
    k++,m=m+5,a[i]=(1LL<<31)-1,i=0;

    }
    cout<<k<<' '<<m;
    return 0;
    }

    t2

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int q[5100],n,m,a,b,x,k;
    void work1()
    {
    for(int i=x;i>=1;i--)
    {
    if(q[x]<q[i]) k--;
    if(k==0) {cout<<i<<endl;break;}
    }
    if(k>0) cout<<-1<<endl;
    }
    void work2()
    {
    for(int i=x;i<=n;i++)
    {
    if(q[x]<q[i]) k--;
    if(k==0) {cout<<i<<endl;break;}
    }
    if(k>0) cout<<-1<<endl;
    }
    void work3()
    {
    for(int i=x;i>=1;i--)
    {
    if(q[i]<q[x]) k--;
    if(k==0) {cout<<i<<endl;break;}
    }
    if(k>0) cout<<-1<<endl;
    }
    void work4()
    {
    for(int i=x;i<=n;i++)
    {
    if(q[i]<q[x]) k--;
    if(k==0) {cout<<i<<endl;break;}
    }
    if(k>0) cout<<-1<<endl;
    }
    int main()
    {
    freopen("T2.in","r",stdin);
    freopen("T2.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>q[i];
    for(int i=1;i<=m;i++)
    {
    cin>>a>>b>>x>>k;
    if(a==0)
    {
    if(b==0) work3();
    if(b==1) work1();
    }
    if(a==1)
    {
    if(b==0) work4();
    if(b==1) work2();
    }
    }
    }

     t3

    #include<iostream>
    #include<cstdio>
    using namespace std;
    long long N,a,b,c;
    long long t1=0,t2=0,sum;
    int main(){
    freopen("T3.in","r",stdin);
    freopen("T3.out","w",stdout);
    cin>>N;
    t1=10,t2=99;
    sum=9;
    int k=2;
    for(;N>=sum;k++){
    N-=sum;
    sum=(t2-t1+1)*k;
    t2=t2*10+9;
    t1*=10;
    }
    k--;
    a=1;
    for(int i=2;i<=k;i++)
    a*=10;
    a+=N/k;
    b=N%k;
    if(b==0)
    a--,b+=k;
    c=k-b;
    for(int i=1;i<=c;i++)
    a/=10;
    cout<<a%10<<endl;
    return 0;
    }

  • 相关阅读:
    jQuery中的DOM操作
    jQuery选择器
    面试问题总结
    oracle日期操作
    Oracle报错:ORA-02064: distributed operation not supported
    JDK源码-String
    JDK源码-HashSet
    JDK源码-TreeMap
    JDK源码-Vector
    AJAX验证用户是否存在
  • 原文地址:https://www.cnblogs.com/lclde/p/7274606.html
Copyright © 2020-2023  润新知