1. 程式人生 > >Codeforces Round #439 (Div. 2)【A、B、C】

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

ring open 方法 tar index none 矩形 %d 個數

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】