跳到正文

Ethereal_Wu

970398

Per Aspera Ad Astra. || luogu.me 查看主页

在洛谷打开
资料、奖项与版本

资料

编号
970398
抓取

版本

  1. v3当前
  2. v2
  3. v1
Per Aspera Ad Astra.\textup{\textbf{{\color{#39C5BB}Per Aspera}{ \color{#66CCFF}Ad Astra.}}} Hello, World!\texttt{Hello, World!}

星铁uid: 114404082114404082 ,求强力助战,求大佬加我。

胡桃厨。银狼厨。miku厨。天依厨。蒟蒻音游人。


My Blog\large{\textup{\textbf{My Blog}}} 正在努力更新中… \ldots\ (目前还有点简陋请见谅啦qwq


一些实用工具:

对拍器
C++
#include<iostream>
#include<Windows.h>
#include<time.h>
using namespace std;
int main() {
	int id = 0;
	while(1) {
		system("gen.exe > test.in");
		system("std.exe < test.in > std.out");
		double bg = clock();
		system("my.exe < test.in > my.out");
		double ed = clock();
		printf(">> test no.%d...\n", ++id);
		if(system("fc std.out my.out")) {
			break;
		}
		printf("cpu time is %.0lf ms\n\n", ed - bg);
	}
	return 0;
}
常用颜色

你能认出她们是谁吗?

#39C5BB{\color{#39C5BB}\texttt{\#39C5BB}}

#FFC0CB{\color{#FFC0CB}\texttt{\#FFC0CB}}

#FFA500{\color{#FFA500}\texttt{\#FFA500}}

#FFE211{\color{#FFE211}\texttt{\#FFE211}}

#66CCFF{\color{#66ccff}\texttt{\#66CCFF}}

#EE0000{\color{#EE0000}\texttt{\#EE0000}}

#EE82EE{\color{#EE82EE}\texttt{\#EE82EE}}

超级快读快写

支持:

  • 连续读入、连续输出;

  • 多类型混合读入、多类型混合输出;

  • int、long long、__int128、string、char 类型变量快速读入;

  • int、long long、__int128、string 类型变量、字符串常量快速输出;

  • 连续输出时自定义分隔符。

C++
#include<cstdio>
#define SUBMIT
namespace Hatsune {
	#ifdef SUBMIT
	#define SIZE (1<<22)
	char in[SIZE], out[SIZE], *p1 = in, *p2 = in, *p3 = out;
	#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,SIZE,stdin),p1==p2)?EOF:*p1++)
	#define flush() (fwrite(out,1,p3-out,stdout),p3=out)
	#define putchar(ch) (p3==out+SIZE&&flush(),*p3++=(ch))
	class Flush { public:~Flush() { flush(); } }_;
	#endif
	namespace Miku {
		inline void read(char &x) { 
			x = getchar(); 
			while(x==' ' || x=='\n' || x=='\r' || x=='\t') x = getchar();
		}
		inline void read(string &x) {
			x.clear(); char ch = getchar();
			while(ch==' ' || ch=='\n' || ch=='\r' || ch=='\t') ch = getchar();
			while(ch!=' ' && ch!='\n' && ch!='\r' && ch!='\t' && ch!=EOF)
				x.push_back(ch), ch=getchar();
		}
		template<typename type>
		inline void read(type& x) {
			x = 0; bool flag(0); char ch = getchar();
			while(ch < '0' || ch>'9') flag ^= ch == '-', ch = getchar();
			while(ch >= '0' && ch <= '9') x = (x<<1)+(x<<3)+(ch^48), ch = getchar();
			flag ? x = -x : 0;
		}
		template<typename type, typename ...T>
		inline void read(type &x, T&...y) { read(x); read(y...); }
		/*- read & write -*/ 
		inline void _write(const char* x, bool flag) {
			if (!x) return;
			while (*x) putchar(*x++);
			flag ? putchar('\n') : putchar(' ');
		}
		inline void _write(char* x, bool flag) { _write((const char*)x, flag); }
		inline void _write(string &x, bool flag) {
			for (char c : x) putchar(c);
			flag ? putchar('\n') : putchar(' ');
		}
		template<typename type>
		inline void _write(type x, bool flag) {
			x < 0 ? x = -x, putchar('-') : 0; short Stack[50], top(0);
			do Stack[++top] = x % 10, x /= 10; while (x);
			while(top) putchar(Stack[top--] | 48);
			flag ? putchar('\n') : putchar(' ');
		}
		inline void write() {}
		template<typename type>
		inline void write(type x) { _write(x, 1); }
		template<typename type, typename ...T>
		inline void write(type x, T...y) { _write(x, 0); write(y...); }
	}
	#ifdef SUBMIT
	#undef SIZE
	#undef getchar
	#undef putchar
	#undef flush
	#endif
}using Hatsune::Miku::read; using Hatsune::Miku::write;
链接
代码折叠框

洛谷的实现方式:

Markdown
\:::info/success/warning/error[Your Title Here]

\```language
\```

\:::

使用 HTML 标签的实现方式:

Markdown
<details>
<summary><font color="" size="">Your Title Here</font></summary>

\```Language
\```

</details>
memset 常用值

int & long long

“较”的原则:加法不爆。

极大值:0x7f

极小值:0x80

较大值:0x3f

较小值:0xc0

double

“较”的原则:保证一定位精度。

极大值:0x7f

极小值:0xfe

较大值:0x43

较小值:0xc2

缺省源
C++
#include <bits/stdc++.h>
#ifdef _WIN32
#include <windows.h>
#include <psapi.h>
#else
#include <sys/resource.h>
#endif
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MIKU 0
using namespace std;
namespace YZWU {

void main() {
	fastio;

	return;
}

}
double peakMEM() {
#ifdef _WIN32
	PROCESS_MEMORY_COUNTERS p;
	GetProcessMemoryInfo(GetCurrentProcess(), &p, sizeof(p));
	return p.PeakWorkingSetSize/1024.0/1024.0;
#else
	rusage r; getrusage(RUSAGE_SELF, &r);
	return r.ru_maxrss/1024.0;
#endif
}
signed main() {
	auto st = chrono::steady_clock::now();
	YZWU::main();
	cerr<<"\nUse: "<<peakMEM()<<"MiB & "
		<<chrono::duration<double, milli>(chrono::steady_clock::now()-st).count()<<"ms.\n";
	return MIKU;
}
共 1 篇
  1. 算法·理论

    扩展 Lucas 定理(exLucas)详解,一文带你彻底看懂扩展 Lucas 定理。

    扩展Lucas定理用于计算组合数C(n,r)模合数m的值,其核心思路为: 质因数分解:将模数m分解为互质的质因子幂次形式m = p₁^a₁ * p₂^a₂ * ... * pₙ^aₙ; 构造同余方程组:对每个p_i^a_i,计算C(n,r) mod p_i^a_i的值r_i,通过Legendre公式求出n!中质因子p的次数v_p(n!),并利用递归公式计算(n!)去掉所有p因子后的值(n!)_p; 中国剩余定理(CRT)合并:将所有r_i通过CRT合并为最终结果。 具体实现中,需处理分母与模数不互质的问题,通过将组合数表示为p^v * [(n!)_p / (r!(n-r)!)_p] mod p^a的形式,其中v为v_p(n!)-v_p(r!)-v_p((n-r)!))。若v≥a,则结果为0;否则需计算分子与分母的逆元并结合p的幂次。算法复杂度为O(√m + Σlog_p n),主要依赖质因数分解和递归预处理阶乘表。模板代码通过BPP结构体实现每个质因子幂次的处理,并在主函数中调用CRT合并结果。典型例题如洛谷P4720和P2183均需此方法解决模数非质数的问题。

    1 赞