codeforces 984补题

codeforces 984a

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int n;
 4 int num[1010];
 5 int main(){
 6     scanf("%d",&n);
 7     for(int i=1;i<=n;i++) scanf("%d",&num[i]);
 8     sort(num+1,num+n+1);
 9     if(n%2==1) printf("%d",num[(n+1)/2]);
10     else printf("%d",num[n/2]);
11     return 0;
12 }

codeforces 984b

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int n,m;
 4 char sz[110][110];
 5 int divs[8][2]={{0,1},{0,-1},{1,0},{-1,0},{-1,-1},{1,-1},{-1,1},{1,1}};
 6 int main(){
 7     while(scanf("%d%d",&n,&m)!=EOF){
 8         for(int i=1;i<=n;i++) scanf("%s",sz[i]+1);
 9         for(int i=1;i<=n;i++){
10             for(int j=1;j<=m;j++){
11                 if(sz[i][j]==‘*‘) continue;
12                 else if(sz[i][j]==‘.‘){
13                     for(int k=0;k<8;k++){
14                         int x=i+divs[k][0],y=j+divs[k][1];
15                         if(x>=1&&x<=n&&y>=1&&y<=m){
16                             if(sz[x][y]==‘*‘){printf("NO\n");return 0;}
17                         }
18                     }
19                 }else{
20                     int num=sz[i][j]-‘0‘;
21                     for(int k=0;k<8;k++){
22                         int x=i+divs[k][0],y=j+divs[k][1];
23                         if(x>=1&&x<=n&&y>=1&&y<=m){
24                             if(sz[x][y]==‘*‘){num--;}
25                         }
26                     }
27                     if(num!=0) { printf("NO\n");return 0;}
28                 }
29                 //if(i==n&&j==m) printf("sbsbsbsb\n");
30             }
31         }
32         //printf("sbbsbsbsbsb\n");
33         printf("YES\n");
34     }
35     return 0;
36 }

先跳过c题补一下d题

codeforces984d 先贴一下链接:看了别人的代码: https://blog.csdn.net/qq_39599067/article/details/80335949

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int n,q;
 4 int num[5010];
 5 int dp[5010][5010],f[5010][5010];
 6 int main(){
 7     scanf("%d",&n);
 8     for(int i=1;i<=n;i++){
 9         scanf("%d",&num[i]);
10         dp[i][i]=f[i][i]=num[i];
11     }
12     for(int j=2;j<=n;j++){
13         for(int i=j-1;i>=1;i--){
14             f[i][j]=f[i][j-1]^f[i+1][j];
15             dp[i][j]=max(f[i][j],max(dp[i][j-1],dp[i+1][j]));
16         }
17     }
18     scanf("%d",&q);
19     while(q--){
20         int l,r;
21         scanf("%d%d",&l,&r);
22         cout<<dp[l][r]<<endl;
23     }
24     return 0;
25 }

codeforces c题 还是贴一个别人的链接  https://blog.csdn.net/xs18952904/article/details/80331434

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 int n;
 5 LL p,q,c;
 6
 7 LL gcd(LL a,LL b){
 8     if(b==0) return a;
 9     else return gcd(b,a%b);
10 }
11
12 int main(){
13     scanf("%d",&n);
14     while(n--){
15         scanf("%lld%lld%lld",&p,&q,&c);
16         //printf("%d\n",gcd(p,q));
17         q=q/gcd(p,q);
18         //printf("%d\n",q);
19         while(gcd(q,c)!=1){
20             LL tmp=gcd(q,c);
21             while(q%tmp==0) q=q/tmp;
22         }
23         if(q==1) printf("Finite\n");
24         else printf("Infinite\n");
25     }
26     return 0;
27 }

原文地址:https://www.cnblogs.com/pandaking/p/9739624.html

时间: 2024-08-01 23:45:26

codeforces 984补题的相关文章

Codeforces VP/补题小记 (持续填坑)

Codeforces VP/补题小记 1149 C. Tree Generator 给你一棵树的括号序列,每次交换两个括号,维护每次交换之后的直径. ? 考虑括号序列维护树的路径信息和,是将左括号看做 \(-1\) ,右括号看做 \(1\) ,那么一段竖直向上的路径可以表示为括号序列的一个区间和,一段竖直向下的路径可以看做括号序列的一个区间和的相反数.我们要维护的是树的直径,也就是一段连续的和减去紧随其后的一段连续的差.具体来说就是 \[ \max_{\forall [l,r]}\{\sum_{

codeforces打完补题

https://codeforces.com/contest/1234/problem/D 写了个巨蠢的线段树(不愧是垃圾),有必要提醒下自己这种题怎么做 #include<iostream> #include<cstdio> #include<string> #include<set> #include<algorithm> using namespace std; const int maxn = 32; set<int> st[

Codeforces 802 补题

A 水题 同B #include<cstdio> #include<cstdlib> #include<cstring> using namespace std; const int maxn=1000000; int n,k,a[maxn],num; bool ex[maxn],need[maxn]; int main() {//freopen("t.txt","r",stdin); scanf("%d%d"

Educational Codeforces Round 24 CF 818 A-G 补题

6月快要结束了 期末也过去大半了 马上就是大三狗了 取消了小学期后20周的学期真心长, 看着各种北方的学校都放假嗨皮了,我们这个在北回归线的学校,还在忍受酷暑. 过年的时候下定决心要拿块ACM的牌子,一直坚持刷题,这一个学期刷了200道吧,感觉还是小有收获.特别是Ural和Codeforces上的题,质量很高. 然后4月的校赛,5月的省赛,发挥的也一般,不过也没有太失常. 希望暑假的选拔赛能碰到有趣的队友 蛤蛤. 这两天各种考试,实在是太忙,看了一下edu24的题目,不是很容易,做了一道水题,以

Educational Codeforces Round 74 (Rated for Div. 2)补题

慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ? ? //√,×,? 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x>y)\),问能否将\(x-y\)拆成任意多个质数之和 1.任意大于\(1\)的整数\(k\)都可以用\(2\)与\(3\)的线性表示 证: 若\(k\)是偶数,显然: 若\(k\)是奇数,则\(k\)可以表示成\(k = 3 + 2*k'\),显然: 毕. #include<bits/stdc++.h&

Codeforces Round #634 (Div. 3) 补题

A. Candies and Two Sisters 签到题,直接输出即可 代码 #include<bits/stdc++.h> #define INF 0x3f3f3f3f typedef long long ll; using namespace std; inline void read(int &p) { p=0;int flag=1;char c=getchar(); while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();} w

4.30-5.1cf补题

//yy:拒绝转载!!! 悄悄告诉你,做题累了,去打两把斗地主就能恢复了喔~~~ //yy:可是我不会斗地主吖("'▽'") ~~~那就听两遍小苹果嘛~~~ 五一假期除了花时间建模,就抽空把最近没做的CF题补了点..毕竟明天开始又要继续上好多课呐...Yes, I can!(? •_•)?……(I can Huá shuǐ~~) codeforces 803 A. Maximal Binary Matrix   [简单构造] 题意:n行和n列填充零矩阵. 您要将k个1放在其中,使得得到

[2015hdu多校联赛补题]hdu5371 Hotaru&#39;s problem

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5371 题意:把一个数字串A翻过来(abc翻过来为cba)的操作为-A,我们称A-AA这样的串为N-sequence,现在给你一个数字串,问你这个串中最长的N-sequence子串长度 解:可以想到A-A是一个回文串,-AA也是一个回文串,那么首先Manacher跑一遍求出所有回文子串 可以想到任意两个互相覆盖的回文子串都可以表示成N-sequence 然后有三种搞法: 1.时间复杂度O(N*logN

补题 留空

这两道题虽然不是很难,但是目前还不会,在这留个地,省赛之后多刷点这种类型的题,再补上. 1. http://acm.hdu.edu.cn/showproblem.php?pid=3306 矩阵快速幂的题,相加平方和. 2.http://acm.hdu.edu.cn/showproblem.php?pid=3308 线段树 补题 留空,码迷,mamicode.com