20pts求调!!

P10836 『FLA - I』歌静河

man_8_24 @ 2024-10-17 10:17:08

rt

20分代码如下

#include <bits/stdc++.h>
#define int long long
using namespace std;
char tmp;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n,m,tshuzujinhaodegeshu=0;
    string s,t;
    cin>>n>>m;
    cin>>s>>t;
    tmp='a';
    for(int i=0;i<n;i++)
    {
        if(t[i]=='#')
        {
            tshuzujinhaodegeshu++;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(s[i]=='#')
        {
            if(tmp!='a'&&tshuzujinhaodegeshu>='z'-tmp)
            {
                tshuzujinhaodegeshu-='z'-tmp;
                tmp='a';
            }   
            s[i]=tmp;
            if(tmp=='z')tmp='a';
            else if(tmp=='a')tmp+=2;
        }
    }
    cout<<s; 
    return 0;
}

by yingxi @ 2024-10-17 10:22:47

@man_8_24 早A了


by man_8_24 @ 2024-10-17 10:23:05

@Baichuzhi @yingxi 我*****


by HSH_starlight @ 2024-10-17 10:23:26

@man_8_24 我也就拿了100而已


by Baichuzhi @ 2024-10-17 10:23:37

#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n , m;
    cin >> n >> m;
    string s , t;
    cin >> s >> t;
    char c = 'a';
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (t[i] == '#')
        {
            cnt++;
        }
    }   
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '#')
        {
            if (c != 'a' && cnt >= 'z' - c + 1)
            {
                cnt -= 'z' - c + 1;
                c = 'a';
            }
            s[i] = c;
            if (c == 'z')
            {
                c = 'a';
            }
            else
            {
                c++;
            }
        }
    }
    cout << s;
    return 0;   
}

代码自己看


by rexmqy @ 2024-10-17 10:24:23

@man_8_24 部分代码:

for(int i=0;i<n;i++)
{
    if(b[i]=='#')
    {
        cnt++;
    }
}
int num=1;
int k=cnt/25;
cnt%=25;    
for(int i=0;i<n;i++)
{
    if(a[i]=='#' and num<=k and k!=0)
    {
        num++;
        a[i]='a';
    }
}
int num1=0;
for(int i=0;i<n;i++)
{
    if(a[i]=='#')
    {
        if(num1+cnt>=26)
        {
            num1=1;
            cnt=cnt+num1-26;
            a[i]='a';
        }
        else
        {
            a[i]=(char)(num1%26+'a');
            num1=(num1+1)%26;
        }
    }
}

不好好上课是吧!!


by QXK20141212 @ 2024-10-17 10:27:56

@man_8_24 没事的


上一页 |