zoukankan      html  css  js  c++  java
  • 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;
    }
    
  • 相关阅读:
    Java核心技术 卷一 笔记四 库类的直接使用
    Java核心技术 卷一 笔记三 大数值及数组
    Java核心技术 卷一 笔记2 字符串的复制
    Java核心技术 卷一 笔记1
    修改css 样式后, hover事件 不生效
    修改 element ui input 输入框 样式不生效问题
    css3 计算属性
    Vue3 改动系列
    浏览器实现,向下滑动 鼠标滚轮,页面横向移动
    linux ceont0s7 vue 打包压缩图片 一直报错
  • 原文地址:https://www.cnblogs.com/roccoshi/p/13027179.html
Copyright © 2011-2022 走看看