A - Rikka with Nash Equilibrium

题意:构造一个$n * m$的矩阵,使得$[1, n * m]$ 中每个数只出现一次,并且纳什均衡只出现一次。

思路:从大到小的放置,每一个都可以拓展一行拓展一列或者放在已经拓展的行列焦点,用记忆化搜索/dp即可

 #include<bits/stdc++.h>

 using namespace std;

 typedef long long ll;

 int n, m;
ll p;
ll dp[][][ * ]; ll DFS(int x, int y,int z)
{
if(z >= n * m) return ;
if(dp[x][y][z] != -) return dp[x][y][z];
ll res = ;
if(x < n) res = (res + y * (n - x) % p * DFS(x + , y, z + )) % p;
if(y < m) res = (res + x * (m - y) % p * DFS(x, y + , z + )) % p;
if(x * y > z) res = (res + (x * y - z) * DFS(x, y, z + )) % p;
dp[x][y][z] = res;
return res;
} int main()
{
int t;
scanf("%d", &t);
while(t--)
{
scanf("%d %d %lld", &n, &m, &p);
memset(dp, -, sizeof dp);
ll ans = DFS(, , );
ans = n * m % p * ans % p;
printf("%lld\n", ans);
}
return ;
}

B - Rikka with Seam

留坑。

C - Rikka with APSP

留坑。

D - Rikka with Stone-Paper-Scissors

题意:每个人有三种牌,"石头、剪刀、布" ,询问第一个人赢第二个人的期望

思路:考虑每一次出牌的概率相同,那么答案就是(赢的情况种数 - 输的情况) / 牌数   那么所有赢输情况种类数就是 $\frac {a_1 *(b_2 - c_2) + b_1 * (c_2 - a_2) + c_1 * (a_2 - b_2)} {a + b + c} $

 #include<bits/stdc++.h>

 using namespace std;

 typedef long long ll;

 ll gcd(ll a, ll b)
{
return b == ? a : gcd(b, a % b);
} ll a1, b1, c1, a2, b2, c2; int main()
{
int t;
scanf("%d", &t);
while(t--)
{
scanf("%lld %lld %lld %lld %lld %lld", &a1, &b1, &c1, &a2, &b2, &c2);
ll ans = a1 * (b2 - c2) + b1 * (c2 - a2) + c1 * (a2 - b2);
if(ans % (a1 + b1 + c1) == )
{
ans /= a1 + b1 + c1;
printf("%lld\n", ans);
}
else
{
int flag = ;
if(ans < )
{
ans = -ans;
flag = ;
}
ll ans2 = a1 + b1 + c1;
ll GCD = gcd(ans, ans2);
ans /= GCD;
ans2 /= GCD;
if(flag) printf("-");
printf("%lld/%lld\n", ans, ans2);
}
}
return ;
}

E - Rikka with Rain

留坑。

F - Rikka with Spanning Tree

留坑。

G - Rikka with Treasure

留坑。

H - Rikka with Line Graph

留坑。

I - Rikka with Bubble Sort

留坑。

J - Rikka with Time Complexity

留坑。

K - Rikka with Badminton

题意:四种人,一种人啥都没有,一种人有拍,一种人有球,一种人有拍有球,求方案数使得有两拍一球

思路:考虑三种选择方案

1° 两个有拍+一个有球

2°两个有拍有球

3°一个有拍,一个有拍有球

答案就是$2^a \cdot 2^c \cdot (2^b - 1) \cdot (2^d - 1) + 2^a \cdot 2^c \cdot (2^d - 1 - d) + 2^a \cdot (2^b - 1 - b) \cdot (2^c - 1)$

 #include <bits/stdc++.h>
using namespace std; #define ll long long const ll MOD = ; ll qmod(ll n)
{
ll res = ;
ll base = ;
while (n)
{
if (n & ) res = res * base % MOD;
base = base * base % MOD;
n >>= ;
}
return res;
} int t;
ll a, b, c, d; int main()
{
scanf("%d", &t);
while (t--)
{
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
ll n = a + b + c + d;
ll res = qmod(a) * qmod(c) % MOD * (qmod(b) - + MOD) % MOD * (qmod(d) - + MOD) % MOD;
res = (res + qmod(a) * qmod(c) % MOD * (qmod(d) - - d + MOD) % MOD) % MOD;
res = (res + qmod(a) * (qmod(b) - - b + MOD) % MOD * (qmod(c) - + MOD)) % MOD;
printf("%lld\n", (qmod(n) - res + MOD) % MOD);
}
return ;
}

2018 Multi-University Training Contest 9 Solution的更多相关文章

  1. 2018 Multi-University Training Contest 1 Solution

    A - Maximum Multiple 题意:给出一个n 找x, y, z 使得$n = x + y +z$ 并且 $n \equiv 0 \pmod x, n \equiv 0 \pmod y, ...

  2. 2018 Multi-University Training Contest 2 Solution

    A - Absolute 留坑. B - Counting Permutations 留坑. C - Cover 留坑. D - Game puts("Yes") #include ...

  3. 2018 Multi-University Training Contest 3 Solution

    A - Problem A. Ascending Rating 题意:给出n个数,给出区间长度m.对于每个区间,初始值的max为0,cnt为0.遇到一个a[i] > ans, 更新ans并且cn ...

  4. 2018 Multi-University Training Contest 4 Solution

    A - Problem A. Integers Exhibition 留坑. B - Problem B. Harvest of Apples 题意:计算$\sum_{i = 0}^{i = m}C( ...

  5. 2018 Multi-University Training Contest 5 Solution

    A - Always Online Unsolved. B - Beautiful Now Solved. 题意: 给出一个n, k  每次可以将n这个数字上的某两位交换,最多交换k次,求交换后的最大 ...

  6. 2018 Multi-University Training Contest 6 Solution

    A - oval-and-rectangle 题意:给出一个椭圆的a 和 b,在$[0, b]中随机选择c$ 使得四个顶点在椭圆上构成一个矩形,求矩形周长期望 思路:求出每种矩形的周长,除以b(积分) ...

  7. 2018 Multi-University Training Contest 7 Solution

    A - Age of Moyu 题意:给出一张图,从1走到n,如果相邻两次走的边的权值不同,花费+1, 否则花费相同,求最小花费 思路:用set记录有当前点的最小花费有多少种方案到达,然后最短路 #i ...

  8. 2018 Multi-University Training Contest 8 Solution

    A - Character Encoding 题意:用m个$0-n-1$的数去构成k,求方案数 思路:当没有0-n-1这个条件是答案为C(k+m-1, m-1),减去有大于的关于n的情况,当有i个n时 ...

  9. 2018 Multi-University Training Contest 10 Solution

    A - Problem A.Alkane 留坑. B - Problem B. Beads 留坑. C - Problem C. Calculate 留坑. D - Problem D. Permut ...

随机推荐

  1. 根据前面的FtpUtil写一个demo

    说说现在开发中一般都是对象化,对于配置文件也不例外. 1.FTPConfig 配置类 /*** * * @author  * */public class FTPConfig { private St ...

  2. <linux系统c语言生成.so文件,生成64位可执行文件,在64位系统中运行32位的可执行文件>

    1.linux 系统c语言生成.o文件,---->gcc -m64 -c -fPIC test.c -o test.o2.linux 系统c语言生成.so文件,----->gcc -sha ...

  3. 【顽固BUG】Visual Studio 2015 + TestDriven.NET-3.8.2860_Personal_Beta 调用的目标发生了异常。

    前言 突然怎么弄也无法断点调试了 输出如下: ------ Test started: Assembly: Server5.V2.dll ------ 调用的目标发生了异常. 而且网站运行提示: -- ...

  4. 使用boch仿真器在x86 PC平台上搭建Linux0.11系统环境(windows下)

    当你有机会来到这页面时   十有八九是遇到这样一个问题    执行配置文件bochsrc_fd.bxrc时出现找不到 ips的情况! 版本原因吧   将boch版本换成2.4的问题就迎刃而解了~ 简单 ...

  5. Android 判断是否是Rtl

    第一种方法: private boolean isRtl() { return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) ...

  6. salt更换新key

    1  停止salt-minion服务 service salt-minion stop 2 删除salt-minion公钥文件 rm /etc/salt/pki/minion/minion.pub r ...

  7. 【BZOJ4099】Trapped in the Haybales Gold STL

    [BZOJ4099]Trapped in the Haybales Gold Description Farmer John has received a shipment of N large ha ...

  8. android 使用动画 Button移动后不响应点击事件的解决办法

    animation3.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimatio ...

  9. postgresql----唯一索引,表达式索引,部分索引

    一.唯一索引 唯一索引字面上理解就是在索引上增加唯一约束,不允许出现索引值相同的行,目前只有Btree索引可以声明唯一索引,唯一键会自动创建唯一索引. 测试表: test=# create table ...

  10. 在github上参与开源项目日常流程

    转载自:http://blog.csdn.net/five3/article/details/9307041 1. 注册帐号 打开https://github.com/,填写注册信息并提交. 2. 登 ...