U133017 天选之人(不确定正确性)

Aimee

很简单的模拟

(未提交)
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,k,p;
int main(){
	scanf("%d%d%d%d",&n,&m,&k,&p);
	if(p*m<=k){
		int tem=k-p*m;
		if(tem<=(m-1)*(n-p)){
			cout<<"Yes"<<endl;
			for(int i=1;i<=p;++i){
				cout<<m<<" 0"<<endl;
			}
			for(int i=1;i<=n-p;++i){
				if(tem>=m-1){
					cout<<m-1<<" "<<1<<endl;
					tem-=(m-1);
				}else{
					cout<<max(0,tem)<<" "<<m-max(0,tem)<<endl;
					tem-=(m-1);
				}
			}
			return 0;
		}else{
			cout<<"No"<<endl;
			return 0;
		} 
	}else{
		//cout<<"Su"<<endl;
		int t=k/p;
		int tem=k-(k/p)*p;
		if(tem<=(t-1)*(n-p)){
			cout<<"Yes"<<endl;
			for(int i=1;i<=p;++i){
				cout<<t<<" "<<m-t<<endl;
			}
			for(int i=1;i<=n-p;++i){
				if(tem>=t-1){
					cout<<t-1<<" "<<m-t+1<<endl;
					tem-=(t-1);
				}else{
					cout<<max(0,tem)<<" "<<m-max(0,tem)<<endl;
					tem-=(t-1);
				}
			}
			return 0;
		}else{
			cout<<"No"<<endl;
			return 0;
		} 
	}
	return 0;
} +
posted @ 2020-11-28 18:41  Simex  阅读(71)  评论(0编辑  收藏  举报