题目链接
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+(p−2∗q)k2∗pk
#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;
}