#define inf 0x7fffffff#define ll long long#define int long long//#define double long double#define eps 1e-8//#define mod 1e9+7``using nam_caddi programmi">
当前位置:   article > 正文

Caddi Programming Contest 2021(AtCoder Beginner Contest 193) A--D

caddi programming contest 2021(atcoder beginner contest 193)

传送门

A - Discount

在这里插入图片描述

#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define int long long
//#define double long double
#define eps 1e-8
//#define mod 1e9+7``
using namespace std;
const int mod=1e9+7;
const int M=2e3+5;
const int N=2*1e5+5;//?????????? 4e8
double n,m; 
signed main()
{
//	ios::sync_with_stdio(false);
	cin>>n>>m;
	m=n-m;
	printf("%.3lf",100.0*m/n);
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

B - Play Snuke

在这里插入图片描述

#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
//#define int long long
//#define double long double
#define eps 1e-8
//#define mod 1e9+7
using namespace std;
const int mod=1e9+7;
const int M=2e3+5;
const int N=2*1e5+5;//?????????? 4e8
int x,y,z;
int n;
int ans=1<<30; 
signed main()
{
//	ios::sync_with_stdio(false);
	cin>>n;
	while(n--)
	{
		scanf("%d%d%d",&x,&y,&z);
		if(z>x)  ans=min(ans,y); 
	}
	if(ans!=1<<30)  printf("%d\n",ans);
	else  puts("-1");
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

C - Unexpressed

在这里插入图片描述

#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define int long long
//#define double long double
#define eps 1e-8
//#define mod 1e9+7
using namespace std;
const int mod=1e9+7;
const int M=2e3+5;
const int N=2*1e5+5;//?????????? 4e8
int n,m;
int prime[N],v[N];
int ans;
map < int , bool > mp;
signed main()
{
//	ios::sync_with_stdio(false);
	cin>>n;
	m=sqrt(n);
	for(int i=1;i<=m;i++)
	{
		if(mp[i])  continue;
		int j=i;
		mp[i]=1;
		if(i==1)  continue;
		while(j<=n)
		{
			j=i*j;
			if(j>n)  break;
			ans++;
			mp[j]=1;
		}
	}
	cout<<n-ans;
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39

D - Poker(其实就是排列问题,只不过坑点贼多)

在这里插入图片描述

#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define int long long
//#define double long double
#define eps 1e-8
//#define mod 1e9+7
using namespace std;
const int mod=1e9+7;
const int M=2e3+5;
const int N=2*1e5+5;//?????????? 4e8
int n;
int c1,c2;
int cnt1,cnt2;
string s1,s2;
int v1[15],v2[15];
int sum1,sum2;
int use[15];
int power(int a,int b)
{
	int sum=1;
	while(b)
	{
		if(b&1)  sum=sum*a;
		a=a*a;
		b>>=1;
	}
	return sum;
}
signed main()
{
//	ios::sync_with_stdio(false);
	cin>>n;
	cin>>s1>>s2;
	for(int i=0;i<4;i++)  v1[s1[i]-'0']++,v2[s2[i]-'0']++;
	for(int i=1;i<=9;i++)  use[i]=n-v1[i]-v2[i];
	for(int i=1;i<=9;i++)
	{
		sum1+=i*power(10,v1[i]);
		sum2+=i*power(10,v2[i]);
	}
	for(int i=1;i<=9;i++)
	{
		int temp=sum1;
		if(!use[i])  continue;
		sum1-=i*power(10,v1[i]);
		sum1+=i*power(10,v1[i]+1);
		for(int j=1;j<=9;j++)
		{
			int t=sum2;
			if(!use[j])  continue;
			sum2-=j*power(10,v2[j]);
			sum2+=j*power(10,v2[j]+1);
			if(sum1>sum2)  
			{
				if(i!=j)  c1+=use[i]*use[j];
				else   c1+=max((int)0,use[i]*(use[j]-1));
			}
			sum2=t;
		}
		sum1=temp;
	}
	printf("%.7lf\n",(double)((double)c1/((double)((9*n-8)*(9*n-9)))));
	return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/506346
推荐阅读
相关标签
  

闽ICP备14008679号