找'long long long',在线等,急
查看原帖
找'long long long',在线等,急
933906
WZwangchongming楼主2024/3/24 23:01

‘long long long’对 GCC 来说太长了

在哪里?完了我是眼瞎嘛

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iomanip>

namespace fastIO {
	inline int read() {
		int res = 0, f = 1;
		char ch = getchar();
		while( !(ch >= '0' && ch <= '9') ) {
			if(ch == '-') f = -1;
			ch = getchar();
		}
		while(ch >= '0' && ch <= '9') {
			res = (res << 1) + (res << 3) + (ch ^ 48);
			ch = getchar();
		}
		return res * f;
	}

	void write(int x) {
		static int sta[35];
		int top = 0;
		do {
			sta[top++] = x % 10;
			x /= 10;
		} while(x);
		while(top) putchar(sta[--top] ^ 48);
	}

	void writeln(int x) {
		write(x);
		putchar('\n');
	}
}

using namespace std;
using namespace fastIO;

#define int long long
#include <cmath>
int n, m;
const int maxn = 200005;
int a[maxn], f[maxn][21];
int t, mod;

void buildST(int u) {
	f[u][0] = a[u];
	for(int i = 1; u - (1 << i) >= 0; i++)
		f[u][i] = max(f[u][i - 1], f[ u - (1 << (i - 1)) ][i - 1]);
}

int RMQ(int x, int y) {
	int t = log(y - x) / log(2);
	return max(f[y][t], f[x + (1 << t) - 1][t]);
}

signed main() {
	
	cin >> m >> mod;
	for(int i = 1; i <= m; i++) {
		char opt;
		cin >> opt;
		if(opt == 'A') {
			int x;
			cin >> x;
			a[++n] = (x + t) % mod;
			buildST(n);
		} 
		else {
			int x;
			cin >> x;
			if(x == 1) {
				cout << a[n] << '\n';
				t = a[n];
				continue;
			}
			int ans = RMQ(n - x + 1, n);
			cout << ans << '\n';
			t = ans;
		}
	} 

//	printf("\n");
//	cout<<"The time used: ";
//	printf("%.2lfs",(double)clock()/CLOCKS_PER_SEC);

	return 0;

}







2024/3/24 23:01
加载中...