Codeforces Beta Round #61 (Div. 2)

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