Codeforces Beta Round #61 (Div. 2)

http://codeforces.com/contest/66

A

输入用long double

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 #define pb push_back
 7 #define eb emplace_back
 8 #define maxn 1000006
 9 #define rep(k,i,j) for(int k=i;k<j;k++)
10 typedef long long ll;
11 typedef unsigned long long ull;
12
13 int main(){
14     #ifndef ONLINE_JUDGE
15         freopen("input.txt","r",stdin);
16     #endif
17     std::ios::sync_with_stdio(false);
18     long double n;
19     cin>>n;
20     if(n>=-128&&n<=127) cout<<"byte"<<endl;
21     else if(n>=-32768&&n<=32767) cout<<"short"<<endl;
22     else if(n>=-2147483648&&n<=2147483647) cout<<"int"<<endl;
23     else if(n<9223372036854775808) cout<<"long"<<endl;
24     else{
25         cout<<"BigInteger"<<endl;
26     }
27 }

View Code

B

暴力枚举每一个数即可

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 #define pb push_back
 7 #define eb emplace_back
 8 #define maxn 1000006
 9 #define rep(k,i,j) for(int k=i;k<j;k++)
10 typedef long long ll;
11 typedef unsigned long long ull;
12
13 int a[1005];
14
15 int main(){
16     #ifndef ONLINE_JUDGE
17    //     freopen("input.txt","r",stdin);
18     #endif
19     std::ios::sync_with_stdio(false);
20     int n;
21     cin>>n;
22     for(int i=1;i<=n;i++){
23         cin>>a[i];
24     }
25     int ans=1;
26     for(int i=1;i<=n;i++){
27         int j=i-1;
28         int co=1;
29         while(j>=1){
30             if(a[j+1]>=a[j]){
31                 j--;
32                 co++;
33             }
34             else{
35                 break;
36             }
37         }
38         j=i+1;
39         while(j<=n){
40             if(a[j-1]>=a[j]){
41                 j++;
42                 co++;
43             }
44             else{
45                 break;
46             }
47         }
48         if(co>ans) ans=co;
49     }
50     cout<<ans<<endl;
51 }

View Code

C

模拟题

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 #define pb push_back
 7 #define eb emplace_back
 8 #define maxn 1000006
 9 #define rep(k,i,j) for(int k=i;k<j;k++)
10 typedef long long ll;
11 typedef unsigned long long ull;
12
13 string s,t;
14 int res1,res2;
15 map<string,int> M,N;
16
17 int main(){
18     #ifndef ONLINE_JUDGE
19         freopen("input.txt","r",stdin);
20     #endif
21     std::ios::sync_with_stdio(false);
22     while(cin>>t)
23     {
24         s=t;
25         int F=0;
26         while(1)
27         {
28             int x=s.find_last_of('\\');
29             if (x==2) break;
30             s=s.substr(0,x);
31             int f=N[s];
32             M[s]+=F;
33             N[s]++;
34             res1=max(res1,M[s]);
35             res2=max(res2,N[s]);
36             if (!f) F++;
37         }
38     }
39     cout<<res1<<' '<<res2<<endl;
40 }

View Code

D

找出3个数,使他们两两的公约数互不为1,他们三个的公约数为1,剩下的数就输出他们的倍数即可

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 #define pb push_back
 7 #define eb emplace_back
 8 #define maxn 1000006
 9 #define rep(k,i,j) for(int k=i;k<j;k++)
10 typedef long long ll;
11 typedef unsigned long long ull;
12
13 int a[3]={6,10,15};
14
15 int main(){
16     #ifndef ONLINE_JUDGE
17      //   freopen("input.txt","r",stdin);
18     #endif
19     std::ios::sync_with_stdio(false);
20     int n;
21     cin>>n;
22     if(n==2){
23         cout<<-1<<endl;
24     }
25     else{
26         for(int i=0;i<n;i++){
27             if(i<3){
28                 cout<<a[i]<<endl;
29             }
30             else{
31                 cout<<6*i<<endl;
32             }
33         }
34     }
35 }

View Code

E

找出a[i]-b[i]前缀和的最小值,然后依次减去,如果发现minn大于等于0的情况,说明走的通,逆向同理

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 #define pb push_back
 7 #define eb emplace_back
 8 #define maxn 1000006
 9 #define rep(k,i,j) for(int k=i;k<j;k++)
10 typedef long long ll;
11 typedef unsigned long long ull;
12
13 int n;
14 int a[100005];
15 int b[100005];
16 set<int>se;
17 set<int>::iterator it;
18
19 void func(int x){
20     int minn=a[0]-b[0],pre=minn;
21     for(int i=1;i<n;i++){
22         pre+=a[i]-b[i];
23         minn=min(minn,pre);
24     }
25     for(int i=0;i<n;i++){
26         if(minn>=0){
27             if(x){
28                 se.insert(i+1);
29             }
30             else{
31                 se.insert(n-i);
32             }
33         }
34         minn-=a[i]-b[i];
35     }
36 }
37
38 int main(){
39     #ifndef ONLINE_JUDGE
40      //   freopen("input.txt","r",stdin);
41     #endif
42     std::ios::sync_with_stdio(false);
43     cin>>n;
44     rep(i,0,n) cin>>a[i];
45     rep(i,0,n) cin>>b[i];
46     func(1);
47     reverse(a,a+n);
48     reverse(b,b+n-1);
49     func(0);
50     cout<<se.size()<<endl;
51     for(it=se.begin();it!=se.end();it++){
52         cout<<*it<<" ";
53     }
54 }

View Code

转载于:https://www.cnblogs.com/Fighting-sh/p/10456922.html

Codeforces Beta Round #61 (Div. 2)相关推荐

  1. Codeforces Beta Round #22 (Div. 2 Only) E. Scheme(DFS+强连通)

    题目大意 给了 n(2<=n<=105) 个点,从每个点 u 出发连向了一个点 v(共 n 条边) 现在要求添加最少的边使得整个图是一个强连通图 做法分析 这道题千万不要一般化:先求强连通 ...

  2. Codeforces Beta Round #4 (Div. 2 Only)

    Codeforces Beta Round #4 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 ...

  3. Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树。单点更新

    http://codeforces.com/problemset/problem/91/B 题意: 给你n个数,求得i 到n中小于a[i]的最右边的a[j],然后求a[i]到a[j]之间包含了多少个数 ...

  4. Codeforces Beta Round #92 (Div. 1 Only) A. Prime Permutation 暴力

    A. Prime Permutation 题目连接: http://www.codeforces.com/contest/123/problem/A Description You are given ...

  5. Codeforces Beta Round #9 (Div. 2 Only) D. How many trees? dp

    D. How many trees? 题目连接: http://www.codeforces.com/contest/9/problem/D Description In one very old t ...

  6. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  7. Codeforces Beta Round #96 (Div. 1) D. Constants in the language of Shakespeare 贪心

    D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codef ...

  8. Codeforces Beta Round #9 (Div. 2 Only) C. Hexadecimal's Numbers dfs

    C. Hexadecimal's Numbers 题目连接: http://www.codeforces.com/contest/9/problem/C Description One beautif ...

  9. Codeforces Beta Round #16 (Div. 2 Only)【未完结】

    2022.3.9 题目地址:https://codeforces.com/contest/16 目录 A. Flag[模拟] B. Burglar and Matches[贪心] C. Monitor ...

  10. Codeforces Beta Round #14 (Div. 2)【未完结】

    2022.3.8 题单地址:https://codeforces.com/contest/14 目录 A. Letter B. Young Photographer[差分] C. Four Segme ...

最新文章

  1. 实验四 使用C++的mfc实现圆心为任意位置的圆的绘制。
  2. windows 连Linux,Windows下访问Linux资源
  3. HDU 1412 {A} + {B}
  4. elisa标准曲线怎么做_ELISA标准曲线制作
  5. NOI提高级:排序算法
  6. ssm mysql 插入date 数据_SSM中插入数据没有报错,但是数据库没有值?报错-问答-阿里云开发者社区-阿里云...
  7. 解决VS2017中出现'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead这问题
  8. 【报告分享】2021年中国新经济企业500强发展研究报告.pdf(附下载链接)
  9. php+crontab+shell方案实现的秒级定时发起异步请求回调方案
  10. MFC 教程【14_SOCKET类的设计和实现】
  11. 中国电信运营商布局云计算“赛道”面临三大挑战
  12. Mac上安装PL/SQL Developer
  13. 《深入浅出WPF》笔记——资源篇
  14. 【Ad Hoc】贰 AODV 协议详解
  15. BuildTools下载地址
  16. 信息系统安全 总结提纲
  17. 中科院计算机研究所排名,中国科学院计算技术研究所
  18. socket函数接口
  19. mac下 iterm+Zsh+Oh My Zsh+tmux 配置方案
  20. 060616信用证点滴简结(三)--D/P即期跟单托收

热门文章

  1. CNN(卷积神经网络)
  2. 计算机组成原理——第五章
  3. 今天突然出现了Property IsLocked is not available for Login '[sa]',我太阳,下面有绝招对付它!...
  4. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_04 IO字节流_10_字节输入流一次读取一个字节的原理...
  5. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_02 递归_3_练习_使用递归计算阶乘...
  6. linux源代码阅读笔记 高速缓冲区管理
  7. CentOS6 图形界面(gnome)安装(转)
  8. MD5加密、Base64加密解密
  9. 使用@AspectJ注解开发Spring AOP
  10. html5新增标签/删除标签