记录编号 483603 评测结果 AAAWAAAATTTTTTTTTTTT
题目名称 2708.颓题面 最终得分 35
用户昵称 __stdcall 是否通过 未通过
代码语言 C++ 运行时间 13.417 s
提交时间 2018-01-18 09:27:23 内存使用 4.65 MiB
显示代码纯文本
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N = 600010;
int _w;

int n, m, a[N], vis[N];

void input() {
	ll x, a, b, c;
	ll y, u, v, w;
	cin >> x >> a >> b >> c;
	cin >> y >> u >> v >> w;
	for( int i = 1; i <= n; ++i )
		::a[i] = i;
	while( m-- ) {
		x = (a*x*x + b*x + c) % n + 1;
		y = (u*y*y + v*y + w) % n + 1;
		swap( ::a[x], ::a[y] );
	}
}

int main() {
	freopen( "tui_problem.in", "r", stdin );
	freopen( "tui_problem.out", "w", stdout );
	cin >> n >> m;
	input();
	int ans = 0;
	for( int i = 1; i <= n; ++i ) {
		for( int j = 1; j <= n; ++j )
			vis[j] = 0;
		int cnt = 0;
		for( int j = i; j <= n; ++j ) {
			int x = a[j];
			vis[x] = 1;
			if( vis[x-1] ) --cnt;
			if( vis[x+1] ) --cnt;
			if( j-i+1+cnt <= 2 ) ++ans;
		}
	}
	cout << ans-n << endl;
	return 0;
}