cf_1293_AB

For A problem, because its k is limited, there is no need to manage n ranges, as long as [n-1500, n + 1500] Add k then circulated again on the line, of course, 1500 is casual, like 2000 is required.

What is the code:

#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int vis[3000]={0};
int main(){
    int t;
    cin>>t;
    while(t--){
        memset(vis,0,sizeof vis);
        int n,s,k;
        cin>>n>>s>>k;int i,j;
        for(i=0;i<k;i++){
            cin>>j;
            if(abs(s-j)<3000)
            vis[abs(s-j)]++;
        }
        if(vis[0]==0){
            cout<<0<<endl;
            continue;
        }
        for(int i=1;i<3000;i++){
                if(s-i>0&&i+s<=n){
                    if(vis[i]!=2){
                cout<<i<<endl;
                break;
                    }
                }else{
                    if(vis[i]!=1){
                        cout<<i<<endl;
                        break;
                    }
                }
 
        }
    }
    return 0;
}
A

As for the B title, if they find a law that every reduction of one person, money is always the most you can:

#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int main(){
    int n;
    cin>>n;
    double sum=0;
    for(int i=n;i>0;i--){
        sum+=1.0/i;
    }
    printf("%.12f\n",sum);
    return 0;
}
B

Guess you like

Origin www.cnblogs.com/Ean1zhi/p/12216744.html