BestCoder Round #85 1001 1002
来源:互联网 发布:淘宝数据包解压工具 编辑:程序博客网 时间:2024/05/16 01:42
这次比赛点背啊,真是遗憾又只拿了一题,可悲的是第一题跪了,当时脑子热了下,还有被bestcoder的Accepect给骗了,就没在意T_T。
1001题意:给你个序列和一个m判断是否存在连续子序列和是m的倍数。
思路:从开始加到最后当和对m取余时出现重复说明可以组成,否则NO。
代码如下:
#include<cstdio>#include<algorithm>#include<cstring>using namespace std;typedef long long LL;#define INF 0x3f3f3f3fint a[100005],b[100005];int main(){ int t,n,m; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); for(int i=0;i<n;i++) { scanf("%d",&a[i]); } int ans=0,flag=0; memset(b,0,sizeof(b)); b[0]=1; for(int i=0;i<n;i++) { ans+=a[i]; ans%=m; if(b[ans]) { flag=1;break; } else b[ans]=1; } if(flag) printf("YES\n"); else printf("NO\n"); }}1002
这题注意的是如果相邻的骨牌之间距离为n那么前一个骨牌想击倒后一个骨牌就得需要n+1的高度,我们将距离排序然后去掉k-1个较大的距离即将这几个骨牌高度设为1.
代码如下:
#include<cstdio>#include<algorithm>#include<cstring>using namespace std;typedef long long LL;#define INF 0x3f3f3f3fint d[100005];int main(){ int t,n,k; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&k); for(int i=0;i<n-1;i++) { scanf("%d",&d[i]); } if(k>=n) { printf("%d\n",n);continue; } sort(d,d+n-1); LL sum=0; for(int i=0;i<n-k;i++) { sum+=(d[i]+1); } printf("%I64d\n",sum+k); }}
0 0
- BestCoder Round #85 1001 1002
- BestCoder Round #85 1002 domino
- BestCoder Round #85 1001 sum
- Bestcoder Round #48 1001、1002
- BestCoder Round #85
- BestCoder Round #85
- BestCoder Round #85题解
- BestCoder Round #85
- BestCoder Round #85
- BestCoder Round #85
- BestCoder Round #85
- BestCoder Round #85 前三题
- BestCoder Round #85题解
- BestCoder Round #15 1002
- BestCoder Round #20 1002
- BestCoder Round #21 1002
- BestCoder Round #80 1002
- BestCoder Round #86 1002
- hdoj-1023-Train Problem II
- PHP5.4.36 RHEL6.5 源码编译安装
- UVALive 6611 Alice's Print Service(二分)
- iOS-截取字符串中两个指定字符串中间的字符串
- hdoj-2512-一卡通大冒险
- BestCoder Round #85 1001 1002
- UVALive 6613 Collision(物理解方程)
- 树莓派 使用xbox360手柄
- URAL 2025 Line Fighting 水题、贪心、均分
- C++ const的那些事
- 河南多校大一训练赛(贪心)
- break与return的作用
- 10019---访问远程Redis服务。Connect to Remote Redis Server
- Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks