Round100(全)

/**/  第一题
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
const double pai=2.0*acos( -1 );
using namespace std;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n,r,R;
	while(cin >> n >> R >> r){
		if(r>R){
			cout<<"NO"<<endl;
		} else if(2*r>=R){
			if(2*r == R ){
				if( n <= 2){
					cout << "YES" << endl;
				}else {
					cout << "NO" << endl;
				}
			}else {
				if( n==1 ){
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
		    }
			}

		} else {
			double a=2.0* asin( ( double ) r / ( R-r ) ) * n ;
			// cout << a <<endl;
			if(( pai-a ) > - 1e-8 ){
				cout << "YES" << endl;
			}else{
				cout << "NO" << endl;
			}
		}
	}
	return 0;

}
/**/

 
 

/**/第二题
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;
struct node
{
	int num,id;
	bool operator <( const node & t)const{
		return t.id>id;
	}
}a[305];
vector<node>vec[305];
map<int,int>mp;
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n;
	int love[305][305];
	scanf("%d", &n);
	for ( int i = 1; i <= n; i++){
		for ( int j = 1;j <= n; j++){
			scanf("%d", &love[i][j]);
		}
	}
	int num;
	for ( int i = 1;i <= n; i ++){
		scanf("%d", &num);
		a[i].num=num,a[i].id=i;
		mp[num]=i;
	}
	for(int i = 1; i <= n; i ++){
		for(int j=1;j<=i;j++){
			// cout<<a[mp[j]].num<<endl;
			vec[i].push_back(a[mp[j]]);
		}
		sort(vec[i].begin(),vec[i].end());
	}
	int vis[305];
	for(int i = 1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(love[i][j]==i){
				continue;
			}
			int u=vec[love[i][j]][0].num;
			if(u==i){
				if(vec[love[i][j]].size()<2)continue;
				if(vec[love[i][j]][1].num==love[i][j]){
					vis[i]=love[i][j];
					break;
				}else{
					continue;
				}
			}else{
				if(u!=love[i][j]){
					continue;
				}
				vis[i]=u;
				break;
			}
		}
	}
	for(int i = 1; i <= n; i ++){
		if(i==1){
			printf("%d", vis[i]);
		}else {
			printf(" %d", vis[i]);
		}
	}
	printf("\n");
	return 0;
}
/**/


/**/第三题
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

map<int,int>mp;
bool cmp(int x,int y){
	return x>y;
}
int a[100005];
struct node{
	int num,name;
	bool operator <(const node& t)const {
		return t.num>num;
	}
}b[100005];

priority_queue<node>q;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n;
	scanf("%d",&n);
	for ( int i = 0; i < n; i ++){
		scanf("%d", &a[i]);
		mp[a[i]]++;
	}
	sort( a, a + n );
	int m = unique( a, a + n )-a;
	for(int i = 0; i < m; i ++){
		b[i].num = mp[a[i]];
		b[i].name = a[i];
		q.push(b[i]);
	}
	// while(q.size()){
	// 	cout<<q.top().name<<" "<<q.top().num<<endl;
	// 	q.pop();
	// }
	int ans[100005];
	int cnt=0,sum=0;
	int vis[5];
	while(q.size()>=3){
		sum++;
		node x1=q.top();
		x1.num--;
		q.pop();
		node x2=q.top();
		x2.num--;
		q.pop();
		node x3=q.top();
		x3.num--;
		q.pop();
		vis[0]=x1.name,vis[1]=x2.name,vis[2]=x3.name;
		// cout<<x1<<" "<<x2<<" "<<x3<<endl;
		sort(vis,vis+3,cmp);
		ans[cnt++]=vis[0],ans[cnt++]=vis[1],ans[cnt++]=vis[2];
		if(x1.num){
			q.push(x1);
		}
		if(x2.num){
			q.push(x2);
		}
		if(x3.num){
			q.push(x3);
		}
	}
	printf("%d\n", sum);
	for(int i=0;i<cnt;i+=3){
		printf("%d %d %d\n",ans[i],ans[i+1],ans[i+2]);
	}
	return 0;
}
/**/


/**/第四题
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	int n;
	int a[105];
	scanf("%d", &n);
	for ( int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
	}
	int time=350,cnt=0,i;
	sort(a + 1, a + 1 + n);
	for(i = 1; i <= n; i++){
		if(time < a[i]){
			break;
		}
		time -= a[i];
		cnt++;
	}
	a[i] -= time;
	time = 0;
	int tim=0;
	for(int j = i; j <= n; j++){
		if(time + a[j] <= 360){
			cnt ++;
			time += a[j];
			tim+=time;
		}else{
			break;
		}
	}
	printf("%d %d\n", cnt, tim);
	return 0;
}
/**/
/**/第五题
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;
LL c[5005],a[5005],d[5005][5005],sum[2],num[1000005],dp[2][5005];
int n,m;
LL p;
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	scanf("%d%d%lld", &n, &m, &p);
	for( int i = 1; i <= n; i++){
		scanf("%lld", &num[i]);
	}
	d[0][0]=1;
	for(int i = 1; i <= 5000; i++){
		for( int j = 1; j <= i; j++){
			d[i][j] = (d[i - 1][j - 1] + (LL) (j - 1) * d[i - 1][j] % p) % p;
			// cout << d[i][j] << endl;
		}
	}
	c[0]=1;
	for( int i = 1; i <= 5000; i++){
		c[i] = (LL) i * c[i - 1] % p;
	}

	a[0]=1;
	for(int i = 1; i <= 5000; i++){
		a[i] = (LL) (m - i + 1) * a[i - 1] % p;
	}
	sum[0] = 1;
	for(int i = 1;i <= n; i++){
		sum[i % 2] = 0;
		for(int j = 1; j <= num[i]; j++){
			dp[i % 2][j] = a[j] * sum[1 - i % 2] % p * d[num[i]][j] % p;
			if(i && j <= num[i - 1]){
				dp[i % 2][j] = (dp[i % 2][j] - c[j] * dp[1 - i % 2][j] % p * d[num[i]][j] % p + p) % p;
			}
			sum[i % 2] = (sum[i % 2] + dp[i % 2][j]) % p;
		}
		// cout << sum[i%2] << endl;
	}
	printf("%lld\n", sum[n % 2]);
	return 0;
}
/**/
/**/第六题
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

typedef pair<int, int> p;
set<p> vis, ans, a;
p arr[200005];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	int n, k;
	scanf("%d%d", &n, &k);
	if(n <= k){
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < n; i++){
		scanf("%d%d", &arr[i].first, &arr[i].second);
		a.insert(arr[i]);
	}
	sort(arr, arr + n);
	for (int i = 0; i <= k; i++){
		for (int j = n - k - 1; j < n; j++){
			p p1(arr[i].first + arr[j].first, arr[i].second + arr[j].second);
			if (vis.count(p1)) continue;
			vis.insert(p1);
			int cnt = 0;
			for (int x = 0; x < n && cnt <= k; x++){
				cnt += ! a.count(p (p1.first - arr[x].first, p1.second - arr[x].second));
			}
			if (cnt <= k){
				ans.insert(p1);
			}
		}
	}
	printf("%d\n", (int) ans.size());
	set<p>::iterator it;
	for (it = ans.begin(); it != ans.end(); it++){
		 // printf("%d %d\n", (it->first), (it->second));
		 printf("%.1lf %.1lf\n", (double)(it->first)/2, (double)(it->second)/2);
	}

	return 0;
}
/**/



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值