求助,90分,望大佬指导
查看原帖
求助,90分,望大佬指导
991844
Wang_Bohao_0122楼主2024/1/18 16:37

怪了,第三测试点不过

#include<bits/stdc++.h>
using namespace std;
int p,e,sum,ans;
int main(){
	cin>>p>>e;
	if(e==0||p==0){
		cout<<"Error";
				return 0;
		}
	if(p*2<e){
		cout<<"Error";
		return 0;
	}
	if(p==e){
		cout<<"0 "<<p;
		return 0;
	}
	for(int i=1;i<=p;i++){
		sum=i;
				ans=p-i;
		if((i*2)+(p-i)==e){
			break;
		}
		

	}
	cout<<sum<<" "<<ans;
return 0;
}
2024/1/18 16:37
加载中...