CF935

CF935

CF935A

link

CF935A题意

n n n 名员工中选几名员工作为团队领导,要求每个人都应该对相同数量的员工负责。而且,每一个不是团队领导的员工,都必须在一个团队的领导下负责,没有团队领导负责另一个团队的领导。
对于员工的数量 n n n F a f a Fafa Fafa可以用多少种方式来选择团队领导者的数量,这样就可以平均分配员工?
输入仅一个正整数 n n n 2 ≤ n ≤ 1 0 5 2\le n\le10^5 2n105
输出仅一行,为分配方案的数量

CF935A题解

读懂题意即可

CF935A代码

#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0, f = 1;char ch =getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
    return x * f;
}
int n;
signed main(){
    n = read();int cnt = 0;
    for(int i = sqrt(n);i;i--){
        if(n % i == 0){cnt += 2;}
    }
    int x = sqrt(n);if(x * x == n)cnt--;
    printf("%d\n",cnt - 1);
    return 0;
}

CF935B

link

CF935B题意

给出一个平面直角坐标系,初始在 ( 0 , 0 ) (0,0) (0,0),每次穿过 y = x y=x y=x 都需要花费一块钱。
给出一个移动序列,问花了多少钱。(特别的,刚开始第一步移动永远不会花钱)

CF935B题解

模拟注意细节

CF935B代码

#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0, f = 1;char ch =getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
    return x * f;
}
int n;char ch;
signed main(){
    n = read();ch = getchar();while(ch == ' ' || ch == '\n')ch = getchar();
    int x = 0, y = 0, cnt = 0;
    bool side = (ch == 'U');
    if(ch == 'U')y = 1;else x = 1;
    for(int i = 2;i <= n;i++){
        // printf("%d %d %d\n",x,y,side);
        ch = getchar();
        if(ch == 'U'){
            if(x == y && side == 0){cnt++;side = 1;}
            y++;
        }
        else{
            if(x == y && side == 1){cnt++;side = 0;}
            x++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

CF935C

link

CF935C题意

给一个已知圆,给另一个点,要求你给出一个圆满足

  • 这个圆覆盖已知圆面积尽可能大
  • 这个圆必须完全在圆内
  • 这个圆不能包含另一个点,但可以让这个点在圆周上

要求你给出这个圆圆心坐标和半径

CF935C题解

设向量 a ⃗ = ( x 2 − x 1 , y 2 − y 1 ) \vec{a}= (x_2-x_1,y_2-y_1) a =(x2x1,y2y1)

  • a ⃗ = = 0 ⃗ \vec{a}==\vec{0} a ==0 :这个圆的一条直径是原来的圆的半径,并且过圆心。
  • ∣ a ⃗ ∣ > R |\vec{a}|>R a >R:这个圆就是原来的圆。
  • 否则:半径是 ∣ a ⃗ ∣ + R 2 \frac{|\vec{a}|+R}{2} 2a +R,圆心坐标是 ( x 1 , y 1 ) + a ⃗ ( ∣ a ⃗ − R ∣ ) 2 ∣ a ⃗ ∣ (x_1,y_1)+\frac{\vec{a}(|\vec{a}-R|)}{2|\vec{a}|} (x1,y1)+2∣a a (a R)

没了。

CF935C代码

#include<bits/stdc++.h>
using namespace std;
double R, x_1,x_2,y_1,y_2;
signed main(){
    scanf("%lf%lf%lf%lf%lf",&R,&x_1,&y_1,&x_2,&y_2);
    double len = sqrt((x_1 - x_2) * (x_1 - x_2) + (y_1 - y_2) * (y_1 - y_2));
    if(len > R){printf("%.7lf %.7lf %.7lf\n",x_1,y_1,R);}
    else if(x_1 == x_2 && y_1 == y_2){printf("%.7lf %.7lf %.7lf\n",x_1 + R / 2.0,y_1,R / 2.0);}
    else printf("%.7lf %.7lf %.7lf\n"
    ,x_1 + ((len - R) * (x_2 - x_1) / len / 2.0)
    ,y_1 + ((len - R) * (y_2 - y_1) / len / 2.0)
    ,(R + len) / 2.0);
    return 0;
}

CF935D

link

CF935D题意

给出两个长度为 n n n 的序列,其中有 0 0 0 的位置等概率的填入小于 m m m 的数,问第一个序列字典序比第二个大的概率是多少?答案对 1 0 9 + 7 10^9+7 109+7 取模

CF935D题解

这玩应不需要DP,直接递推就好了
记录一个变量 t i m e s times times,初始为 1 1 1,表示前 i i i 位相等的概率

  • a i ≠ 0 , b i ≠ 0 a_i\neq 0,b_i\neq 0 ai=0bi=0:判断下这俩相不相等,如果不相等后面填啥玩应都没用了
  • a i = 0 , b i = 0 a_i=0,b_i=0 ai=0bi=0 a n s + = m − 1 2 m , t i m e s × = 1 m ans+=\frac{m-1}{2m},times\times=\frac{1}{m} ans+=2mm1times×=m1
  • a i ≠ 0 , b i = 0 a_i\neq 0,b_i=0 ai=0bi=0: a n s + = m − b i m , t i m e s × = 1 m ans+=\frac{m-b_i}{m},times\times=\frac{1}{m} ans+=mmbitimes×=m1
  • a i = 0 , b i ≠ 0 a_i=0,b_i\neq 0 ai=0,bi=0 a n s + = a i − 1 m , t i m e s × = 1 m ans+=\frac{a_i-1}{m},times\times=\frac{1}{m} ans+=mai1times×=m1

最后输出下 a n s ans ans 就好了
然后就没了

CF935D代码

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int x = 0, f = 1;char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
    return x * f;
}
const int maxn = 1e5 + 10, mod = 1e9 + 7;
int a[maxn], b[maxn];
int n, m;
int qpow(int x,int a){
    int res = 1;
    while(a){
        if(a & 1)res = (res * x) % mod;
        x = x * x % mod;a >>= 1;
    }
    return res;
}
int sum[maxn];
int frac(int x,int y){return x * qpow(y,mod - 2) % mod;}
signed main(){
    n = read(); m = read();
    for(int i = 1;i <= n;i++)a[i] = read();
    for(int i = 1;i <= n;i++)b[i] = read();
    int times = 1, ans = 0;
    for(int i = 1;i <= n;i++){
        if(a[i] && b[i] && a[i] != b[i]){printf("%lld",(ans + (a[i] > b[i]) * times % mod) % mod);return 0;}
        if(a[i] && !b[i]){ans = (ans + frac(a[i] - 1,m) * times % mod) % mod;times = times * frac(1, m) % mod;}
        if(!a[i] && b[i]){ans = (ans + frac(m - b[i],m) * times % mod) % mod;times = times * frac(1, m) % mod;}
        if(!a[i] && !b[i]){ans = (ans + frac(m - 1,2 * m) * times % mod) % mod;times = times * frac(1, m) % mod;}
    }
    printf("%lld\n",ans);
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值