AtCoder Beginner Contest 242
Posted nike0good
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AtCoder Beginner Contest 242相关的知识,希望对你有一定的参考价值。
A - T-shirt
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 100 points
Problem Statement
In a certain programming contest, T-shirts are awarded to participants according to the following rules.
All participants who ranked A-th or higher get a T-shirt.
Additionally, from the participants who ranked between (A+1)-th and B-th (inclusive), C participants chosen uniformly at random get a T-shirt.
There were 1000 participants in this contest, and all of them got different ranks.
Iroha-chan, who participated in this contest, ranked X-th.
Find the probability that she gets a T-shirt.
Constraints
All values in input are integers.
1≤A<B≤1000
1≤C≤B−A
1≤X≤1000
Input
Input is given from Standard Input in the following format:
A B C X
Output
Print the answer. Your output will be considered correct if the absolute or relative error from the judge’s answer is at most 10^−6
.
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) \\
For(j,m-1) cout<<a[i][j]<<' ';\\
cout<<a[i][m]<<endl; \\
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b)return (a*b)%F;
ll add(ll a,ll b)return (a+b)%F;
ll sub(ll a,ll b)return ((a-b)%F+F)%F;
void upd(ll &a,ll b)a=(a%F+b%F)%F;
inline int read()
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) if (ch=='-') f=-1; ch=getchar();
while(isdigit(ch)) x=x*10+ch-'0'; ch=getchar();
return x*f;
int main()
// freopen("A.in","r",stdin);
// freopen(".out","w",stdout);
double a,b,c,x;
cin>>a>>b>>c>>x;
if(x<=a) cout<<"1"<<endl;
else if(a+1<=x&&x<=b)
cout<<(double)(c)/(b-a)<<endl;
else cout<<0<<endl;
return 0;
B - Minimize Ordering
You are given a string S. Find the lexicographically smallest string S’ obtained by permuting the characters of S.
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) \\
For(j,m-1) cout<<a[i][j]<<' ';\\
cout<<a[i][m]<<endl; \\
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b)return (a*b)%F;
ll add(ll a,ll b)return (a+b)%F;
ll sub(ll a,ll b)return ((a-b)%F+F)%F;
void upd(ll &a,ll b)a=(a%F+b%F)%F;
inline int read()
int x=0,f=1; char ch=getchar();
while(!isdigit(ch)) if (ch=='-') f=-1; ch=getchar();
while(isdigit(ch)) x=x*10+ch-'0'; ch=getchar();
return x*f;
int main()
// freopen("B.in","r",stdin);
// freopen(".out","w",stdout);
char s[212345];
cin>>(s+1);
int n=strlen(s+1);
sort(s+1,s+n+1);
cout<<(s+1);
return 0;
C - 1111gal password
Given an integer
N
N
N, find the number of integers
X
X
X that satisfy all of the following conditions, modulo
998244353
998244353
998244353. 以上是关于AtCoder Beginner Contest 242的主要内容,如果未能解决你的问题,请参考以下文章 AtCoder Beginner Contest 115 题解
X
X
X is an
N
N
N-digit positive integer.
Let
X
i
X_i
Xi be the digits of X from top to bottom. They satisfy all of the following:
1
≤
X
i
≤
9
1\\le X_i \\le 9
1≤Xi≤9 for all integers
1
≤
i
≤
N
1≤i≤N
1≤i≤N
∣
X
i
−
X
i
+
1
∣
≤
1
∣X_i −X_i+1∣≤1
∣Xi−Xi+1∣≤1 for all integers
1
≤
i
≤
N
−
1
1≤i≤N−1
1≤i≤N−1