暑假刷题第22天--8/5

4118. 狗和猫 - AcWing题库(模拟)

#include
#include
#include
#include 
#include
#include
#include
#include
using namespace std;
int cnt=0;
void solve(){
	cnt++;
	printf("Case #%d: ",cnt);
	int n,d,c,m;
	cin>>n>>d>>c>>m;
	string s;
	cin>>s;
	for(int i=0;i>t;
	while(t--){
		solve();
	}
} 

Problem - A - Codeforces

#include
#include
#include
#include 
#include
#include
#include
#include
using namespace std;
const int N=200005;
int a[N];
void solve(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x==i)ans++;
	}
	cout<>t;
	while(t--){
		solve();
	}
} 

Problem - B - Codeforces

#include
#include
#include
#include 
#include
#include
#include
#include
using namespace std;
const int N=200005;
int a[N];
void solve(){
	long long n;
	cin>>n;
	int cnt=0;
	int ans=0;
	for(int i=1;i<=1000;i++){
		if(n%i==0)cnt++;
		else cnt=0;
		ans=max(ans,cnt);
	}
	cout<>t;
	while(t--){
		solve();
	}
} 

Problem - C1 - Codeforces

#include
#include
#include
#include 
#include
#include
#include
#include
using namespace std;
const int N=200005;
long long a[25];
void solve(){
	vector >q;
	int n;
	cin>>n;
	int ans=0;
	int p1,p2;
	int ma=-55;
	int mi=55;
	for(int i=0;i>a[i];
		if(a[i]>ma){
			ma=a[i];
			p1=i;
		}
		if(a[i]abs(ma)||(ma==mi&&ma<0)){
		for(int i=0;i0){
				a[i]+=mi;
				ans++;
				q.push_back({i,p2});
			}
		}
		for(int i=n-2;i>=0;i--){
			ans++;
			q.push_back({i,i+1}); 
		}
	}
	else {
		for(int i=0;i>t;
	while(t--){
		solve();
	}
} 

Problem - C2 - Codeforces

#include
#include
#include
#include 
#include
#include
#include
#include
using namespace std;
#define int long long
long long a[25];
long long b[25];
typedef pairPII;
void solve(){
	int f;
        vector vz;
        vector vf;
        int n,nmax=-55,dn,nmin=55,xn;  cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            b[i]=a[i];
            if(a[i]>nmax){
                dn=i;
                nmax=a[i];
            }
            if(a[i]0&&nmin<0){
            while(a[dn]a[i]){
                    a[i]+=a[i-1];
                    vz.push_back({i,i-1});
                }
            }

            while(abs(b[xn])0){
                    b[i]+=b[xn];
                    vf.push_back({i,xn});
                }
            }
            for(int i=n;i>1;i--){
                if(b[i-1]>b[i]){
                    b[i-1]+=b[i];
                    vf.push_back({i-1,i});
                }
            }
            if(vz.size()>=vf.size()){
                f=2;
            }else{
                f=1;
            }
        }else if(nmin>=0){
            for(int i=2;i<=n;i++){
                if(a[i-1]>a[i]){
                    a[i]+=a[i-1];
                    vz.push_back({i,i-1});
                }
            }
            f=1;
        }else{
            for(int i=n;i>1;i--){
                if(b[i-1]>b[i]){
                    b[i-1]+=b[i];
                    vf.push_back({i-1,i});
                }
            }
            f=2;
        }
        if(f==1){
            cout<>t;
	while(t--){
		solve();
	}
} 

你可能感兴趣的:(暑假打卡,算法,c++,数据结构)