
刷题日记
wanderist.
……
展开
-
有关高精阶乘的一点思考
起因//从大佬那抄的#include<cstdio>#include<algorithm>#include<vector>using std::vector;using std::swap;typedef long long ll;const int N=1e6+10;const ll P=998244353;const ll G=3;ll read(){ ll a=0;int op=1;char ch=getchar(); whil原创 2021-08-23 21:45:00 · 107 阅读 · 0 评论 -
有关幻方.
一道水题#include<cstdio>using namespace std;int n,a[40][40],x,y;int main(){ scanf("%d",&n); x=1,y=(n+1)/2; for(int i=1;i<=n*n;i++){ a[x][y]=i; if(!a[(x-2+n)%n+1][y%n+1]) x=(x-2+n)%n+1,y=y%n+1; else x=x%n+1;//数学运算 } for(int i=1;i<原创 2021-08-09 15:54:49 · 85 阅读 · 0 评论 -
lgP1320
#include <cstdio>int d[40020],i=1; // d 记录压缩码(显然恒小于等于 40002 ) , i 用来记录存储的位置char c; // 临时存储字符int main(){ for(;scanf("%c",&c)&&c>0x2F;) // 先读入第一行,不断读入,直到 c 不是 ‘0’(0x30) 和 ‘1’ (0x31) 为止。 i+=!(i&1^(c-0x30)),d[i]++,原创 2021-08-08 14:10:23 · 77 阅读 · 0 评论 -
一道红题.
洛谷P5731#include<cstdio>using namespace std;int read(){//没啥用的快读 int x=0,f=1; char c=getchar(); while(c<'0'||c>'9'){ if(c=='-') f=-1; c=getchar(); } while(c>='0'&&c<='9'){ x=x*10+c-'0'; c=getchar(); } return x*f;}原创 2021-08-02 16:20:19 · 99 阅读 · 0 评论 -
贪心训练日记
1.陶陶摘苹果luoguP1478贪心贪心假设:在所有可以摘到的苹果中,优先选择需要力气小的苹果。贪心证明:因为要求的是共能摘多少个苹果,所以我们可以将每个苹果的价值都视为1。那么无论是摘比较费劲的苹果还是比较省力的苹果所得到的价值都是一样的。但如果摘比较省力的苹果,就可以留下更多的力气去摘其他的苹果。#include<iostream>#include<algorithm>using namespace std;const int N=5100;int n;int原创 2020-08-24 15:46:52 · 164 阅读 · 0 评论 -
动态规划训练日记
1.洛谷P1244青蛙过河原创 2020-08-22 20:42:06 · 145 阅读 · 0 评论 -
DFS训练日记
洛谷P1019原创 2020-08-20 15:46:31 · 82 阅读 · 0 评论 -
lgP1146 硬币反转
一道经典的规律题:仔细想一次反转n-1个数,和一次反转一个数实际上时等价的。#include<iostream>using namespace std;int n;const int MAX=110;bool vt[MAX];int a[MAX];int main(){ cin>>n; cout<<n<<endl; for (int i=1;i<=n;i++){ for (int j=1;j<=n;j++){ i原创 2020-08-16 15:32:57 · 117 阅读 · 0 评论