码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #439 (Div. 2)【A、B、C】

时间:2017-10-07 15:01:52      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:can   数学   ons   font   blog   阶乘   names   set   force   

Codeforces Round #439 (Div. 2)

 

codeforces 869 A. The Artful Expedient

看不透(

技术分享
1 #include<cstdio>
2 int main(){
3     puts("Karen");
4     return 0;
5 }
15ms

codeforces 869B. The Eternal Immortality(数学,水)

题意:输出两个数的阶乘的商的 个位数

题解:两数之差大于5,个位数就是0。小于5直接个位相乘即可。

技术分享
 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 typedef long long ll;
 6 int main(){
 7     ll a, b, x, y;
 8     scanf("%lld %lld", &a, &b);
 9     if(b-a>=5) puts("0");
10     else {
11         ll d = b - a; ll t = 1;
12         x = b % 10;
13         for(int i = 0 ; i < d; ++i) t *= (x-i);
14         printf("%lld\n", t%10);
15     }
16     return 0;
17 }
15ms

codeforces 869 C. The Intriguing Obsession(dp)

题意:给出三种颜色岛屿的数量,问有多少种建桥方法。限制是:对于相同颜色的岛屿,要么不能直接相连,要么最少相距为3。

技术分享
 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 typedef long long ll;
 6 const ll mod = 998244353;
 7 const int N = 5001;
 8 ll c[N][N];
 9 void init() {
10     int i, j;
11     for(i = 0; i < N; ++i) c[0][i] = 1;
12     for(i = 1; i < N; ++i)
13         for(j = i; j < N; ++j)
14             c[i][j]=(c[i-1][j]+c[i-1][j-1]*j)%mod;
15 }
16 int main() {
17     init();
18     int x, y, z;
19     scanf("%d%d%d", &x, &y, &z);
20     if(x>y)swap(x, y); if(x>z)swap(x, z); if(y>z)swap(y,z);
21     printf("%lld\n", (((c[x][y]*c[x][z])%mod)*c[y][z])%mod );
22     return 0;
23 }
140ms

E.题意:给一个n行m列的方格矩形,每格是1*1的单元,有q个操作:t, r1, c1, r2, c2其中t=1表示 以(r1,c1)和(r2,c2)为矩形对角线端点选择相应的矩形,在其内放障碍物;t=2同理移除该矩形内的障碍物;t=3表示 求(r1,c1)能否到达(r2,c2),要求行走时不能通过障碍物。

//不会,,先留着。。

 

Codeforces Round #439 (Div. 2)【A、B、C】

标签:can   数学   ons   font   blog   阶乘   names   set   force   

原文地址:http://www.cnblogs.com/GraceSkyer/p/7633702.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!