2017 ACM-ICPC 亚洲区(西安赛区)网络赛

题目链接


A:https://nanti.jisuanke.com/t/17114
B:https://nanti.jisuanke.com/t/17115
C:https://nanti.jisuanke.com/t/17116
D:https://nanti.jisuanke.com/t/17117
E:https://nanti.jisuanke.com/t/17118
F:https://nanti.jisuanke.com/t/17119
G:https://nanti.jisuanke.com/t/17120
H:https://nanti.jisuanke.com/t/17121
I:https://nanti.jisuanke.com/t/17122
J:https://nanti.jisuanke.com/t/17123
本场比赛我可以是说相当水,做了5个小时的B题最终还没搞出来,本队也只做了2题。唉。

一些题解


C. Sum

 题意非常简单,给定一个x求一个k让k*x后的数字每一位加起来是233的倍数。
 那么这道题所给的数据范围非常大,我们直接不走寻常路,发现不管x是啥数字重复233遍就一定可以符合条件,然后再让这个数除去x就是k那么其实也就是00..1的循环,而零的个数和x的位数一致,去掉首几个零,就是答案。

#include <bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=100010;
int main()
{
    int t,x;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&x);
        int cnt=0;
        while(x>=10)
        {
            x=x/10;
            cnt++;
        }
        printf("1");
        for(int i=2;i<=233;i++)
        {
                for(int j=1;j<=cnt;j++)
                    printf("0");
                printf("1");
        }
        printf("\n");

    }
    return 0;
}

F. Trig Function

 队友说是切比雪夫多项式,表示懵逼つ﹏⊂。

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
typedef long long ll;
ll ex_gcd(ll a,ll b,ll &x,ll &y)
{
    if (a==0&&b==0) return -1;
    if (b==0){x=1;y=0;return a;}
    ll d=ex_gcd(b,a%b,y,x);
    y-=a/b*x;y=(y+mod)%mod;
    return d;
}
int main()
{
    ll n,m;
    while(scanf("%lld%lld",&n,&m)!=EOF)
    {
        ll ans=n,js=1, flag = 1;
        if(m==0)
        {
            if(n&1) ans=0;
            else ans=(n%4==0?1:-1);
            printf("%lld\n",(ans+mod)%mod);
            continue;
        }
        else
        {
            if(n%2==0&&m%2==1||n%2==1&&m%2==0||m>n) printf("0\n");
            else
                {
                for(ll i=n+m-2;i>n-m;i-=2) ans=ans*i%mod;
                for(ll i=1;i<=m;i++) js=js*i%mod;
                ll a = js, b = mod, x, y;
                ex_gcd(a,b,x,y);x=(x+mod)%mod;
                ans = ans * x % mod;
                flag=((abs(n-m)>>1)%2==1?-1:1);
                printf("%lld\n",(ans*flag+mod)%mod);
            }
        }

    }
    return 0;
}

赛后补题


B. Coin

 题目意思是说Bob丢硬币正面朝上的概率是q/p,现在问Bob丢k次以后,正面朝上次数是偶数次的概率。
 结果发现是公式推错了,应该是 pk+(p2q)k2pk

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
LL pow_mod(LL a, LL b, LL p){//a的b次方求余p
    LL ret = 1;
    while(b){
        if(b & 1) ret = (ret * a) % p;
        a = (a * a) % p;
        b >>= 1;
    }
    return ret;
}
LL Fermat(LL a, LL p){//费马求a关于b的逆元
        return pow_mod(a, p-2, p);
}
LL ksm(LL a,LL b)
{
    LL r=1,base=a;
    while(b!=0)
    {
        if(b&1)
            r = r * base % mod;
        base = base * base % mod;
        b>>=1;
    }
    return r;
}

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        LL p, q, k;
        scanf("%lld%lld%lld", &p,&q,&k);
        LL a = ksm(p, k);
        LL b = ksm(p - 2 * q, k);
        LL ans = ((a + b) * Fermat(2 * a, mod))%mod;
        printf("%lld\n", ans);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值