20190804中山晨考Day3 考场心态

这次考试,差点爆零,这是为什么呢,第一题MemoryLimitError 0,woc,好不容易推出了期望dp,TM的,数组开大了,而且我算的没有任何问题。

T1.锻造

Input

第一行两个整数 n, a,含义如题所示。
为了避免输入量过大,第二行五个整数 bx, by, cx, cy, p,按照下列代码
来生成 b 和 c 数组。

b[0]=by+1;c[0]=cy+1;
for(int i=1;i<n;i++){
b[i]=((long long)b[i-1]*bx+by)%p+1;
c[i]=((long long)c[i-1]*cx+cy)%p+1;
}

Output

输出一行一个整数,表示期望花费。

Sample Input

Sample Input1
0 6432
4602677 3944535 2618884 6368297 9477531

Sample Input2
1 3639650
6136976 5520115 2835750 9072363 9302097

Sample Input3
10 2
2 33 6 66 2333333

Sample Input4
200 5708788
0 0 0 0 1

Sample Output

Sample Output1
6432

Sample Output2
150643649

Sample Output3
976750710

Sample Output4
696441597


这道题,有50分的做法,然而我贪了一下,0分QAQ。 真的是,来贴一下我的考场代码吧。

 

#include<bits/stdc++.h>
#define int long long
#define mod 998244353
using namespace std;
inline int read() {
	int x = 0, f = 1;
	char c = getchar();
	while(!isdigit(c)) {
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c)) {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int b[10000001], c[10000001];
int f[10000001], a[10000001];
signed main() {
	freopen("forging.in", "r", stdin);
	freopen("forging.out", "w", stdout);
	int n = read(), s = read();
	if(n == 0) {
		printf("%lld\n", s);
	} else {
		int bx = read(), by = read(), cx = read(), cy = read(), p = read();
		if(p == 1) {
			f[0] = s % mod;
			f[1] = 2 * s % mod;
			for(int i = 2; i <= n; i++) {
				f[i] = (f[i - 1] + f[i - 2]) % mod;
			}
			printf("%lld\n", f[n]);
		} else {
			b[0] = by + 1;
			c[0] = cy + 1;
			int mx = max(b[0], c[0]);
			for (int i = 1; i < n; i++) {
				b[i] = (b[i - 1] * bx + by) % p + 1, mx = max(mx, b[i]);
				c[i] = (c[i - 1] * cx + cy) % p + 1, mx = max(mx, c[i]);
			}
			a[1] = 1;
			for (int i = 2; i <= mx; i++) {
				a[i] = (mod - mod / i) * a[mod % i] % mod;
			}
			f[0] = s;
			f[1] = (a[min(c[0], b[0])] * f[0] % mod * c[0] + f[0]) % mod;
			for (int i = 2; i <= n; i++) {
				f[i] = (a[min(c[i - 1], b[i - 2])] * f[i - 1] % mod * c[i - 1] % mod + f[i - 2]) % mod;
			}
			printf("%lld", f[n]);
		}
	}
	return 0;
}

好吧看一下下一道题

T2.整除

 

 

Sample Input

0
1
2 3
2 3

Sample Output

6

这道题吗,我暴力居然10分,真的是侮辱我的智商,所以,我还是先贴一下我的代码吧。

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read() {
	int x = 0, f = 1;
	char c = getchar();
	while(!isdigit(c)) {
		if(c == '-')f = -1;
		c = getchar();
	}
	while(isdigit(c)) {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
int p[51], t;
inline int ksm(int a, int b, int c) {
	if(b == 0) {
		return 1;
	}
	int tem = ksm(a, b / 2, c) % c;
	int ans = 1;
	if(b % 2 == 1) {
		ans *= a;
	}
	ans *= (tem * tem) % c;
	return ans;
}
signed main() {
	freopen("division.in", "r", stdin);
	freopen("division.out", "w", stdout);
	int id = read();
	int T = read();
	while(T--) {
		int c = read(), m = read(), n = 1, ans = 0;
		for(int i = 1; i <= c; i++) {
			p[i] = read();
			t = max(t, p[i]);
			n *= p[i];
		}
		for(int i = 1; i <= n; i++) {
			int a = ksm(i, m, n) - i;
			while(a < 0) {
				a += n;
			}
			a %= n;
			if(a == 0) {
				ans++;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

 所以说这一道题QAQ,其实很玄学。

T3.欠钱

这题LCT,跳了,上网查就行了。

 

行了,今天就过去了,ByeBye

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值