文章

12

粉丝

0

获赞

12

访问

622

头像
k小数 题解:
P1922 复旦大学2023年机试题
发布于2026年2月25日 16:00
阅读数 29

#include<bits/stdc++.h>
using namespace std;
int n,k,T,a1,a2,b1,b2,c1,c2,d1,d2;
	
long long get_val(int x, int y) {
    double res = (a1 * x + b1 * sin(c1 * x + d1) + a2 * y + b2 * sin(c2 * y + d2)) * T;
    return (long long)res; 
}

long long count_le(long long mid){
	long long cnt = 0;
	int i = 1;
	int j  = n;
	
	while(i <= n && j >= 1){
		if(get_val(i,j) <= mid){
			cnt += j;
			i++;
		}
		else
			j--;
	}
	
	return cnt;
}

int main(){
	
	cin>>n>>k>>T;
	cin>>a1>>b1>>c1>>d1;
	cin>>a2>>b2>>c2>>d2;
	
	long long ans;
	long long low = get_val(1,1);
	long long high = get_val(n,n);
	
	while(low <= high){
		long long mid = (low + high) / 2;
		
		if(count_le(mid) >= k){
			ans = mid;
			high = mid -1;
		}
		else
			low = mid + 1;
		
	}
	
	cout<<ans<<endl;
	
	
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发