标题
增加 1 行删除 1 行
1编译器21编译器
正文
增加 211 行删除 4 行
123456718 行未改动262728293031323334325 行未改动全部展开360361362363364365366367368227 行未改动全部展开596597598599600601602603604187 行未改动全部展开792793794795796```cpp#include<bits/stdc++.h>#include<summer02.h>#define pre(i, l, r) for(int i = (l); i <= (r); ++i)#define fpre(i, r, l) for(int i = (r); i >= (l); --i)#define fr(i, a) for(int _ = (a).size(), i = 0; i < _; ++i)#define ll long long18 行未改动map<string, pair<int,int>> gf;string st[maxn] ={};ll qpow(ll a, ll b, ll p = 0){325 行未改动全部展开ll solve(int L, int R){pre(i, L, R){string &s = st[i - 1];fr(i, s)if(i != _ - 1 && s[i] == '/' && s[i + 1] == '/'){s.erase(i, s.size());227 行未改动全部展开}elseif(op == "endfor"){int tot = 1, u;fpre(j, i - 1, L){string op = str(st[j - 1], 0);if(op == "endfor")187 行未改动全部展开solve(1, n);return 0;}```12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021118 行未改动230231232233234235236237238325 行未改动全部展开564565566567568569570571572227 行未改动全部展开800801802803804805806807808187 行未改动全部展开9969979989991000100110021003如果你的编译器版本是c++11,请将代码中的注释取消注意:函数方面目前有Bug如果不想出bug不要变量名重名。注意一切表达式中间不能有空格。如 `a = b + c`是错误的,应该写成 `a = b+c` 。::::info[使用方法]在终端先输入代码,然后单独一行输入EOF,最后就可以输入数据,代码会输出结果。目前:0、注释:a//something...不解释1、类似 `int a` 类型,即定义一个变量。若想赋值可以 `int a 5` 。若想定义即输入可以 `int a read` , 也可以 赋值 `int a b` 。2、类似 `read a b ...` , 即读入。**若变量不存在会自动创建**。所以定义并读入读入 $n$ 和 $m$ 可以这样: `read n m`3、类似 `write a` , 注意一次只能输出一个整数,且没有输出空格或者换行。后面会提到更好的输出方式4、`add/sub/mul/div/mod/or/xor/and/<</>>/qpow/inv`如 `add a b` 就相当于 `a += b` 。特殊的:`qpow a b` 相当于 `a = qpow(a,b)``inv a b` 相当于将 $a$ 改为 $a$ 在模 $b$ 意义下的乘法逆元。注意由于作者太弱了,是用费马小定理实现的,所以要求 $b$ 是质数。5、 `copy a b`没啥用,将 $b$ 的值赋值给 $a$ 。6、`goto j`这个偶尔采用,会跳转到第 $j$ 行代码7、if op .....endif 如果 op 为真那么会执行下面的代码,到 `endif` 结尾。**注意必须有endif** 。如```cppif 1+1==2do something...//代码endif```8、`delete a`没什么用,删除 `a` 这个变量。9、`swap a b`交换 $a$ 和 $b$ 的值,要求 $a$ 和 $b$ 均为变量10、`putchar s` 输出 $s$ 这个**字符串**,不换行也没啥用,后面有替换的11、`exit/return x`结束进程。如果是在函数里相当于返回一个x。但是暂时函数功能有bug建议不用。12、`++a/--a` 同c++13、`max a b`将 $a$ 变为 $\max (a,b)$14、`min a b`同13,只不过是将 $\max(a,b)$ 改成 $\min(a,b)$ 。15、`puts x` 输出 $x$ 这个字符串并**换行** 。16、`for i l r.......endfor`将 $i$ 从 $l$ 枚举到 $r$ , 中间最好不要重变量名。以`endfor`结尾,**一定要写endfor**如```cppfor i 1 5write iputsendfor```会输出```cpp12345```17、`for i l r c ...endfor`如果 $c >= 0$ , 相当于 `for(int i = l;i <= r;i += c)`否则,就是 `for(int i = l;i >= r;i += c)`18、`while(x)...endwhile`当 $x$ 为真时一直执行。如```cppwhile a < 5 // 注意这里要有空格++awrite aputsendwhile```目前运算符支持 = (相当于==) , ==, !=, <=, >=, <, >19、`array a b` , 定义一个 长度为 $b$ 的名字为 $a$ 的数组,0-based, 用 `a[i]` 访问元素。20、 `a = b/a += b/a -= b/a *= b/a /= b/a <<= b/a >>= b/a &= b/a |= b/a ^= b` 这就是我为什么不建议用前面的 `add a b` 。如果说 `qpow a b` 那可以这样:`a = qpow(a,b)` 而且这样还支持模数,可以 `a=qpow(a,b,p)``inv` 同理。21、`print...` 也很好用。语言不好描述,自己看吧。```cppprint 5+3 ( ) 6 (\nHello,World!\n) 7 (\t5\n) 6-3 (\n6-3)```输出:```cpp8 6Hello,World!7 536-3```有点像printf,完美替代了前面提到的write/putchar/puts(虽然puts还有点用)22、函数目前自带`qpow` `pow`(其实就是快速幂) `abs` `max` `min` `inv` `gcd` `lcm`放心,这些目前没bug,有bug的是手写函数。有BUG,还是不讲了吧但给大家看一下还是可以的。代码:```cppfunction add(a,b)return a+bendfunctionread a bprint add(a,b) (\n)```输入:```cpp5 3```输出:```cpp8```第二种:```cppfunction add(a,b)print a+b (\n)endfunctionread a badd(a,b)```效果一样。::::可以将代码放在 $st$ 数组里,这样就能在OJ上提交了。[【模板】快速幂](https://www.luogu.com.cn/record/264788885)[【A+B problem】](https://www.luogu.com.cn/record/264789017)[【斐波那契数列】](https://www.luogu.com.cn/record/264789261)注意其常数大的离谱,所以只能偶尔玩一玩。[TLE](https://www.luogu.com.cn/record/264789860)```cpp line-numbers#include<bits/stdc++.h>#define pre(i, l, r) for(int i = (l); i <= (r); ++i)#define fpre(i, r, l) for(int i = (r); i >= (l); --i)#define fr(i, a) for(int _ = (a).size(), i = 0; i < _; ++i)#define ll long long18 行未改动map<string, pair<int,int>> gf;string st[maxn] ={};ll qpow(ll a, ll b, ll p = 0){325 行未改动全部展开ll solve(int L, int R){pre(i, L, R){string s = st[i - 1];fr(i, s)if(i != _ - 1 && s[i] == '/' && s[i + 1] == '/'){s.erase(i, s.size());227 行未改动全部展开}elseif(op == "endfor"){int tot = 1, u = 0;fpre(j, i - 1, L){string op = str(st[j - 1], 0);if(op == "endfor")187 行未改动全部展开solve(1, n);return 0;}```