丽泽普及2022交流赛day21 社论

A

暴力 .

greater<double> -> greater<int>

\(100\) -> \(50\)

代码丢了 .

B

dp .

考场上代码抢救一下就过力

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <climits>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
template<typename T>
inline int chkmin(T& a, const T& b){if (a > b) a = b; return a;}
template<typename T>
inline int chkmax(T& a, const T& b){if (a < b) a = b; return a;}
const int N = 114514, P = 1e9+7;
int n;
ll a[N], b[N], dp[N][2];
int main()
{
#ifndef ONLINE_JUDGE
//	freopen("i.in", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%lld", a+i);
	for (int i=1; i<n; i++) scanf("%lld", b+i);
	dp[0][0] = 1; 
	for (int i=1; i<=n; i++)
	{
		dp[i][0] = (a[i] * ((dp[i-1][0] + dp[i-1][1]) % P) % P + b[i-1] * dp[i-1][0] % P + (b[i-1] - 1) * dp[i-1][1]) % P;
		dp[i][1] = b[i] * (dp[i-1][0] + dp[i-1][1]) % P;
	} printf("%lld\n", dp[n][0]);
	return 0;
}

C

玄学

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <climits>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <bitset>
using namespace std;
const int N = 111111;
int n, s, now, a[N], su[N], ans[N];
inline int sum(int l, int r){return su[r] - su[l-1];}
int main()
{
	scanf("%d%d", &n, &s); now = n;
	for (int i=1; i<=n; i++) scanf("%d", a+i), su[i] = su[i-1] + a[i];
	for (int i=n; i>=1; i--)
	{
		while ((now + now-i-1 > n) || (sum(i, now-1) > s) || (sum(now, min(n, now*2-i-1)) > s)) --now;
		ans[i] = (now-i)*2;
	}
	for (int i=1; i<=n; i++) printf("%d\n", ans[i]);
    return 0;
}

D

Fibonacci Nim,我懒得链了,就是上一篇 .

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <climits>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
template<typename T>
inline int chkmin(T& a, const T& b){if (a > b) a = b; return a;}
template<typename T>
inline int chkmax(T& a, const T& b){if (a < b) a = b; return a;}
const ll lim = 74, magic[] = {0ll, 1ll, 1ll, 2ll, 3ll, 5ll, 8ll, 13ll, 21ll, 34ll, 55ll, 89ll, 144ll, 233ll, 377ll, 610ll, 987ll, 1597ll, 2584ll, 4181ll, 6765ll, 10946ll, 17711ll, 28657ll, 46368ll, 75025ll, 121393ll, 196418ll, 317811ll, 514229ll, 832040ll, 1346269ll, 2178309ll, 3524578ll, 5702887ll, 9227465ll, 14930352ll, 24157817ll, 39088169ll, 63245986ll, 102334155ll, 165580141ll, 267914296ll, 433494437ll, 701408733ll, 1134903170ll, 1836311903ll, 2971215073ll, 4807526976ll, 7778742049ll, 12586269025ll, 20365011074ll, 32951280099ll, 53316291173ll, 86267571272ll, 139583862445ll, 225851433717ll, 365435296162ll, 591286729879ll, 956722026041ll, 1548008755920ll, 2504730781961ll, 4052739537881ll, 6557470319842ll, 10610209857723ll, 17167680177565ll, 27777890035288ll, 44945570212853ll, 72723460248141ll, 117669030460994ll, 190392490709135ll, 308061521170129ll, 498454011879264ll, 806515533049393ll, 1304969544928657ll};
ll n;
int main()
{
	scanf("%lld", &n);
	for (int i=1; i<=lim; i++)
		if (magic[i] == n){printf("%lld\n", n); return 0;}
	for (int i=lim; i>=1; i--)
	{
		if (magic[i] < n) n -= magic[i];
		if (magic[i] == n) break;
	}
	printf("%lld\n", n);
	return 0;
}

posted @ 2022-02-18 19:08  Jijidawang  阅读(32)  评论(0编辑  收藏  举报
😅​