• Codeforce Round #643 #645 #646 (Div2)


    codeforce Round #643 #645 #646 div2

    Round #643

    problem A

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    
    ll findmin(ll x){
    	ll minn=99;
    	while(x!=0){
    		if(x%10<minn)
    			minn=x%10;
    		x/=10;
    	}
    	return minn;
    }
    
    ll findmax(ll x){
    	ll maxx=-1;
    	while(x!=0){
    		if(x%10>maxx)
    			maxx=x%10;
    		x/=10;
    	}
    	return maxx;
    }
    
    int main(){
    	int n;scanf("%d",&n);
    	ll a,k;
    	while(n--){
    		scanf("%lld %lld",&a,&k);
    		for(ll i=1;i<=k-1;++i){
    			if(findmin(a)==0)break;
    			a+=findmin(a)*findmax(a);
    		}
    		printf("%lld
    ",a);
    		a=0;
    	}
    	return 0;
    }
    

    problem B

    #include<bits/stdc++.h>
    using namespace std;
    #define N 300005
    int a[N];
    int n,m,sum=0,k=1,tmp;
    
    int main(){	
    	scanf("%d",&n);
    	while(n--){
    		scanf("%d",&m);
    		for(int i=0;i<m;++i){
    			scanf("%d",&a[i]);
    		}
    		sort(a,a+m);
    		tmp=a[0];
    		for(int i=1;i<=m;++i){
    			if(tmp<=k){
    				sum++;k=1;
    				tmp=a[i];
    			}
    			else{
    				tmp=a[i];
    				k++;
    			}
    		}
    		cout<<sum<<endl;
    		k=1;tmp=0;sum=0;
    	}
    	return 0;
    }
    

    Round #645

    problem A

    #include<bits/stdc++.h>
    using namespace std;
     
     
    int main(){
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int k;cin>>k;
    	int n,m;
    	while(k--){
    		cin>>n>>m;
    		if(n*m%2==1)
    			cout<<(n*m+1)/2<<endl;
    		else
    			cout<<n*m/2<<endl;
    	}
    	return 0;
    }
    }
    

    problem B

    #include<bits/stdc++.h>
    using namespace std;
    int a[200005];
    
    int main(){
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int k;cin>>k;
    	int n;
    	int flag=0;
    	while(k--){
    		cin>>n;
    		for(int i=1;i<=n;++i){
    			cin>>a[i];
    		}
    		sort(a+1,a+n+1);
    		for(int i=1;i<=n;++i){
    			if(a[i]<=i)flag=i;
    		}
    		cout<<flag+1<<endl;
    		flag=0;
    		
    	}
    	return 0;
    }
    
    

    problem C

    #include<bits/stdc++.h>
    using namespace std;
    
    int main(){
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	long long x,y,x1,y1,t;cin>>t;
    	while(t--){
    		cin>>x>>y>>x1>>y1;
    		cout<<(x1-x)*(y1-y)+1<<endl;
    	}
    	return 0;
    }
    

    Round #646

    problem A

    #include <bits/stdc++.h>
    using namespace std;
    
    int main()
    {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t, n, x, k;
    cin >> t;
    int sum = 0;
    while (t--)
    {
    	cin >> n >> x;
    	for (int i = 0; i < n; ++i)
    	{	 
    		cin >> k;
    		if (k % 2 == 1)
    		{
    			sum++;
    		}
    	}
    	if ((x == n && sum % 2 == 0) || (sum == 0) || (x % 2 == 0 && sum == n))
    		cout << "No" << endl;
    	else
    		cout << "Yes" << endl;
    }
    	sum = 0;
    return 0;
    }
    

    problem B

    #include <bits/stdc++.h>
    using namespace std;
    
    int main()
    {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int t;
    	cin >> t;
    	string x;
    	int cnt0 = 0, cnt1 = 0;
    	int ans = 9999;
    	int tmp = 0;
    	while (t--)
    	{
    		cin >> x;
    		if (x.size() <= 2)
    			cout << "0" << endl;
    		else if (x.size() == 3)
    		{
    			if (x == "101" || x == "010")
    				cout << "1" << endl;
    			else
    				cout << "0" << endl;
    		}
    		else
    		{
    			for (int i = 0; i < x.size(); ++i)
    			{
    				if (x[i] == '0')
    					cnt0++;
    				else
    					cnt1++;
    			}
    			ans = min(cnt0, cnt1);
    			tmp = cnt0;
    			for (int i = 0; i < x.size(); ++i)
    			{ //ans01
    				if (x[i] == '1')
    					tmp++;
    				else
    					tmp--;
    				if (tmp < ans)
    					ans = tmp;
    			}
    			tmp = cnt1;
    			for (int i = 0; i < x.size(); ++i)
    			{ //ans10
    				if (x[i] == '0')
    					tmp++;
    				else
    					tmp--;
    				if (tmp < ans)
    					ans = tmp;
    			}
    			cout << ans << endl;
    			ans = 9999;
    			cnt0 = 0;
    			cnt1 = 0;
    		}
    	}
    	return 0;
    }
    
  • 相关阅读:
    P3444 [POI2006]ORK-Ploughing
    p4555&bzoj2565 最长双回文串
    bzoj2563 阿狸和桃子的游戏
    p4503&bzoj3555 企鹅QQ
    p3627&bzoj1179 抢掠计划(ATM)
    p2279&bzoj1217 消防局的设立
    p2661 信息传递(Tarjan模板)
    p2071 座位安排
    2B The least round way
    JSK 糟糕的bug
  • 原文地址:https://www.cnblogs.com/roccoshi/p/13027179.html
Copyright © 2020-2023  润新知