5 solutions

  • 0
    @ 2022-3-16 19:21:04

    看到最小操作步数就想到了贪心 然后开始找怎么贪心 原理很好想 就看代码吧

    #include<bits/stdc++.h>
    using namespace std;
    char a[10000];
    char b[10000];
    int main(){
    	cin>>a>>b;
    	int num=0;
    	int sum=0;
    	int num1,num2;
    	for(int i=0;i<strlen(a);i++){
    		if(a[i]!=b[i]){
    			num++;
    			if(num==1){
    				num1=i;
    			}
    			else if(num==2){
    				num2=i;
    				sum=num2-num1+sum;
    				num=0;
    			}
    		}
    	}
    	cout<<sum;
    
    
    	return 0;
    
    }
    

    Information

    ID
    1586
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    45
    Accepted
    26
    Uploaded By