个人学习用

· · 个人记录


class B
{
    int b;
};
struct A : public B
{
    int a;
};
struct C : B
{

};
------------ - # [$CSP$初赛复习](https://www.luogu.com.cn/blog/334586/csp-pre-knowledge) ------------ - # 好用の函数 - $ios::sync$ _ $with$ _ $stdio(false);

在某些题目中,我们使用普通的cin和cout会超时,所以我们每次只能打scanf和printf,然后一堆的占位符巨麻烦),为什么cin和cout比scanf和printf用的时间多? 这是因为C++中,cin和cout要与stdio同步,中间会有一个缓冲,所以导致cin,cout语句输入输出缓慢,这时就可以用这个语句,取消cin,cout与stdio的同步,说白了就是提速,效率基本与scanf和printf一致。

则这段代码会输出8

例如: $int$ $a[100001]={1,43,3,2,3,5}; memset(a,0,sizeof(a));

那么a数组所有位置都为0

- #### [快速幂](https://www.luogu.com.cn/paste/2lj1ut1v)

背包问题:

    f[i][j]=max(f[i-1][j-c[i]]+w[i],f[i-1][j] );//c时间,w数目

无优化

for(int i=1;i<=n;i++)
{
    for(int c=0;c<=m;c++)
    {
        f[i][c]=f[i-1][c];
        if(c>=w[i])
        f[i][c]=max(f[i][c],f[i-1][c-w[i]]+v[i]);
    }
}

Checker对拍:

#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long read()//快读
{
    long long x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}
void write(long long x)//快写
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
const int N=100;//数据范围
int main(){
    for(int i=1;i<=N;i++)
    {
        system("datamaker.exe>data.txt");
        double st1=clock();
        system("mine.exe<data.txt>mine.txt");
        double ed1=clock();
        double st=clock();
        system("std.exe<data.txt>std.txt");
        double ed=clock()
        if(system("fc mine.txt std.txt")) {printf("WA on #%d\n",i);break;}
        else printf("AC #%d Time:(yours:%.3lfms),(stds:%.3lfms)\n",i,ed1-st1,ed-st);
    }
    return 0;
}

造数据专用代码

#include<bits/stdc++.h>
using namespace std;
void work()
{
    long long n,k,r;
    long long l=1e9;
    cin>>n;
        srand(time(0));
    cout<<((((long long)rand())<<32)+(((long long)rand()<<16)+(((long long)rand()))))%(l-r)+r<<endl;
}
int main()
{
    freopen(".in","w",stdout);
    work();
    return 0;
 } 

队列 or 搜索

NOTE

CSP-J T2抱灵经验