帮个忙
查看原帖
帮个忙
701230
Jesusdalao楼主2022/10/29 22:03

超时:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t,n,e,d;
ll p,q,fanwei,x,y;
bool ans;
int main(){
	scanf("%lld",&t);
	for(int i=1;i<=t;i++){
		scanf("%lld%lld%lld",&n,&d,&e);
		x=e*d;
		y=n+2-x;
		fanwei=y/2;
		for(int j=1;j<=fanwei;j++){
			p=j;
			q=y-p;
			if(p*q==n){
				ans=1;
				break;
			}
		}
		if(ans==1) printf("%lld %lld\n",p,q);
		else printf("NO\n");
		ans=0;
	}
	return 0;
}
2022/10/29 22:03
加载中...