暑假刷题第26天--8/15

Problem - A - Codeforces

#include
#include
#include
#include
using namespace std;
const int N=200005;
int a[N];
void solve(){
	int n;
	cin>>n;
	vectorb,c;
	int ma=-1;
	for(int i=0;i>a[i];
		ma=max(a[i],ma);
	}
	for(int i=0;i>t;
	while(t--){
		solve();
	}
} 

Problem - B - Codeforces

#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int N=200005;
int a[N];
void solve(){
	int n;
	cin>>n;
	vectorans;
	int mi=1e9+6;
	for(int i=0;i,greater >q;
		for(int i=0;i>t;
	while(t--){
		solve();
	}
} 

Problem - C - Codeforces(打表)

#include
#include
#include
#include
#include
#include
#include
using namespace std;
const int N=200005;
int a[N];
void solve(){
	int n;
	cin>>n;
	int ans=-1;int q=n;
	for(int k=0;k<=q;k++){
	for(int i=1;i<=k;i++){
		a[i]=i;
	}
	n=q;
	for(int i=k+1;i<=q;i++){
		a[i]=n--;
	}
	long long p1=0;
	for(int i=1;i<=q;i++)p1+=a[i]*i;
	int ma=-1;
	for(int i=1;i<=q;i++)ma=max(a[i]*i,ma);
	if(ans>t;
	while(t--){
		solve();
	}
} 

Status - Codeforces Round 892 (Div. 2) - Codeforces(很好的一道题,主意cin会超时)

#include
#include
#include
#include
using namespace std;
typedef pairPII;
const int N=200005;
void solve(){
	int n;
	cin>>n;
	vectorq;
	vectorans;
	for(int i=1;i<=n;i++){
		int l,r,a,b;
		cin>>l>>r>>a>>b;
		q.push_back({l,b});
	}
	sort(q.begin(),q.end());
	for(int i=0;i>t;
	while(t--){
		int x;
		cin>>x;
		int l=0,r=ans.size()-1;
		while(l>1;
			if(ans[mid].first<=x)l=mid;
			else r=mid-1;
		}
		if(ans[l].first<=x&&ans[l].second>=x)cout<>t;
	while(t--){
		solve();
	}
}

D - M<=ab (atcoder.jp)(二分)

#include
#include
#include
#include
#include
using namespace std;
typedef pairPII;
typedef long long ll;
const int N=1000006;
bool is[N];
int cnt;
int prim[N];
void isp(int n){
	memset(is,0,sizeof(0));
	cnt=0;
	for(int i=2;i>n>>m;
	ll ans=1e16;
	for(long long i=1;i*i-1000000<=m&&i<=n;i++){
		ll l=1,r=n;
		if(r*il){
			ll mid=r+l>>1;
			if(mid*ii*l&&i*l>=m&&i<=n&&l<=n){
			ans=i*l;
		}
	}
        if(ans!=1e16)cout<>t;
	while(t--){
		solve();
	}
}

[ABC295D] Three Days Ago - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)(类似前缀和)

#include
#include
#include
#include
#include
#include
using namespace std;
mapma;
void solve(){
	string s;
	cin>>s;
	int n=s.size();
	long long ans=0;
	string sum="0000000000";
	ma[sum]++;
	for(int i=0;i>t;
	while(t--){
		solve();
	}
}

196. 质数距离 - AcWing题库

#include 
#include 
#include 

using namespace std;

typedef long long LL;

//sqrt(2^31 - 1)
const int N = 1e6 + 10;

bool st[N];
int primes[N], cnt;

void get_primes(int n) {
    memset(st, 0, sizeof st);
    cnt = 0;
    for (int i = 2; i <= n; ++ i) {
        if (!st[i]) primes[cnt ++ ] = i;
        for (int j = 0; primes[j] * i <= n; ++ j) {
            st[primes[j] * i] = true;
            if (i % primes[j] == 0) break;
        }
    }
}

int main() {
    int l, r;
    while (~scanf("%d%d", &l, &r)) {
        get_primes(50000);

        //把[l,r]区间内所有的合数用他们的最小质因子筛掉
        memset(st, 0, sizeof st);
        for (int i = 0; i < cnt; ++ i) {
            LL p = primes[i];
            for (LL j = max(2 * p, (l + p - 1) / p * p); j <= r; j += p)
                st[j - l] = true;
        }

        //剩下的所有的都是素数了
        cnt = 0;
        for (int i = 0; i <= r - l; ++ i)
            if (!st[i] && i + l > 1)
                primes[cnt ++ ] = i + l;

        if (cnt < 2) printf("There are no adjacent primes.\n");
        else {
            //计算间隔
            int minp = 0, maxp = 0;
            for (int i = 0; i + 1 < cnt; ++ i) {
                int d = primes[i + 1] - primes[i];
                if (d < primes[minp + 1] - primes[minp]) minp = i;
                if (d > primes[maxp + 1] - primes[maxp]) maxp = i;
            }
            printf("%d,%d are closest, %d,%d are most distant.\n", 
            primes[minp], primes[minp + 1], 
            primes[maxp], primes[maxp + 1]);
        }
    }
    return 0;
}

你可能感兴趣的:(暑假打卡,c++,算法,数据结构)