2 条题解

  • 0
    @ 2024-12-13 13:16:52
    #include<iostream>
    using namespace std;
    typedef long long ll;
    int n;
    ll k;
    const int N=110;
    int a[N];
    ll m=0,cnt=0;
    int find(ll k)
    {
        ll x=1;
        for(int i=1;;i++)
        {
            x=x*2;
            if(x>=k) 
            {
                m=x;
                return i;
            }
        }
    }
    int main()
    {
        char x='a';
        cin>>k>>n;
        for(int i=0;i<n;i++) cin>>a[i];
        if(k==1)
        {
            cout<<"a";
            return 0;
        }
        while(k>1)
        {
            int x=find(k);
            if(k<=m/2) k=k%(m/2);
            else if(k>m/2)
            {
                if(a[x-1]==0) k=k-m/2;
                else if(a[x-1]==1) 
                {
                    k=k-m/2;
                    cnt++;
                }
            }
        }
        cnt%=26;
        char y=x+cnt;
        cout<<y;
        return 0;
    }
    
    • 0
      @ 2024-12-12 23:27:18
      k, n = map(int, input().split())
      ops = list(map(int, input().split()))
      increase = 0  
      length = 1    
      ls = []
      for op in ops:
          if op == 0:
              length *= 2
          else:
              length += length
          ls.append(length)
      for i in range(n - 1, -1, -1):
          half = ls[i] // 2
          if k > half:
              k -= half
              if ops[i] == 1:
                  increase += 1
      print(chr(ord('a') + (increase % 26)))
      
      • 1

      信息

      ID
      1085
      时间
      1000ms
      内存
      256MiB
      难度
      9
      标签
      递交数
      11
      已通过
      3
      上传者