盘点一些弱智代码

P1001 A+B Problem

wyp20130701 @ 2024-10-14 20:41:21

正常版:

#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0;
}

弱智度:40%:

#include <iostream>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    for (int i = 1;i <= b;i++)
    {
        a++;
    }
    cout << a << endl;
    return 0;
}

弱智度 70%:

#include <iostream>
using namespace std;
int main()
{
    long long a,b;
    cin >> a >> b;
    for (int i = 1;;i++)
    {
        if (i == a + b)
        {
            cout << i;
            break;
        }
    }
    return 0;
}

弱智度 999999%:

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    srand(time(0));
    int a,b;
    cin >> a >> b;
    int ans = rand();
    if (ans == a + b)
    {
        cout << ans << endl;
    }
    else
    {
        while (ans != a + b)
        {
            ans = rand();
        }
        cout << ans << endl;
    }
    return 0;
}

by Civilight_Eterna @ 2024-10-19 15:19:41

@XCH66666 在非Dev的IDE中是可编译运行的


by __Digger__ @ 2024-10-20 17:21:51

你这算啥,看我LCA

#include<bits/stdc++.h>
#define int long long

using namespace std;

const int MAXN = 1e5 + 1;
long long n, m, a, b, root, num[3];
map<int, map<int, int>> st;
map<int, int> deep;
map<int, vector<int>> c;
void dfs(int x, int step) {
    deep[x] = step;
    for(int i = 0; i < c[x].size(); i++) {
        if(deep[c[x][i]] == 0) {
            dfs(c[x][i], step + 1);
            st[c[x][i]][0] = x;
        }
    }
}
int LCA(int x, int y) {
    if(deep[x] > deep[y]) {
        swap(x, y);
    }
    for(int i = 21; i >= 0; i--) {
        if(deep[st[y][i]] >= deep[x]) {
            y = st[y][i];
        }
    }
    if(x == y) {
        return x;
    }
    for(int i = 21; i >= 0; i--) {
        if(st[x][i] != st[y][i]) {
            x = st[x][i], y = st[y][i];
        }
    }
    return st[x][0];
}

signed main() {
//    freopen("tree.in", "r", stdin);
//    freopen("tree.out", "w", stdout);
    cin >> a >> b;
    if(a == b) {
        b += a;
        a = 0;
    }
    c[a + b].push_back(a);
    c[a + b].push_back(b);
    num[0] = a;
    num[1] = b;
    num[2] = a + b;
    dfs(a + b, 1);
    for(int i = 1; i <= 21; i++) {
        for(int j = 0; j < 3; j++) {
            st[num[j]][i] = st[st[num[j]][i - 1]][i - 1];
        }
    }
    cout << LCA(a, b);
    return 0;
}

by XHY___ @ 2024-10-20 22:20:48

太nb了,笑死 (刚学c++,看不懂,但知道很弱智


by 47C2023cty @ 2024-10-21 17:46:36

#include<bits/stdc++.h>
#define int long long
using namespace std;
int a,b;
int ans=0;
int bfs(int x,int y)
{
    ans=x+y;
    return ans;
}
signed main()
{
    cin>>a>>b;
    bfs(a,b);
    cout<<ans;
    return 0;
}

by Tobyzeng1306 @ 2024-10-23 19:08:35

@XCH66666 define了就行


by Tobyzeng1306 @ 2024-10-23 19:09:59

#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    srand(time(0));
    int a,b;
    cin >> a >> b;
    int ans = rand();
    if (ans == a + b)
    {
        cout << ans << endl;
    }
    else
    {
        while (ans != a + b)
        {
            ans = rand();
        }
        cout << ans << endl;
    }
    return 0;
}

全TLE


by ADOFAI_big_old @ 2024-10-23 20:42:40

弱智度 99999999999999999999999999999999999999999999999999999%

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <math.h> 
#include <limits.h> 
#include <locale.h>
#include <cstdlib>
#include <cstring>   
#include <stdio.h>
#include <stdlib.h> 
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <bitset>
#include <cctype>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <stack>   
#include <utility>
#include <vector>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <cwchar>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <queue>
#include <set>
#include <sstream>
#include <bits/stdc++.h>
#include <cwctype>
using namespace std;
struct i{
    long long ia;
};
i a[100000],b[100000],f[100000];
void abc(){
    f[1].ia=0;
    cin>>a[0].ia>>b[0].ia;
    for(long long i=0;i<=0;i++){
        if(a[0].ia==a[0].ia){
            while(1){
                cout<<a[0].ia+b[0].ia;
                f[1].ia=1;
                break;
            }
        }else if(a[0].ia+b[0].ia==a[0].ia+b[0].ia){
            cout<<a[0].ia+b[0].ia;
            f[1].ia=1;
        }else{
            cout<<a[0].ia-a[0].ia+a[0].ia+b[0].ia;
            f[a[0].ia%(a[0].ia-1)].ia=1;
        }
        if(f[1].ia==1){
            break;
        }
    }
    return;
}
int main(){
    abc();
    f[1].ia=0;
    cin>>a[0].ia>>b[0].ia;
    for(long long i=0;i<=0;i++){
        if(a[0].ia==a[0].ia){
            while(1){
                f[1].ia=1;
                break;
            }
        }else if(a[0].ia+b[0].ia==a[0].ia+b[0].ia){
            f[1].ia=1;
        }else{
            f[a[0].ia%(a[0].ia-1)].ia=1;
        }
        if(f[1].ia==1){
            break;
        }
    }
    return 0;
}

笑点解析:代码类型是java


by XQJ001 @ 2024-10-26 15:33:42

include <iostream>

using namespace std;

int main(){ int a,b; cin>>a>>b; cout<<a/aa/aa/aa/aa/aa+b/bb/bb/bb/bb/bb; return 0; }


by fuxueziyi @ 2024-11-03 19:37:03

@wyp20130701 t4level up

#include<bits/stdc++.h>
using namespace std;
int main(){
    srand(time(NULL));
    int a,b,sum;
    cin>>a>>b;
    while(sum!=a+b) sum=rand();
    cout<<sum<<endl;
    return 0;
}

还对了两个点


by crz_qwq @ 2024-11-12 18:53:54

你这算啥?看我文艺平衡树

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
mt19937 rng(time(0));
int root,tot;
struct node{
    int val,pri,ls,rs,sz;
    int sum,maxn;
    int rev,add;
}tr[N];
int New(int x)
{
    ++tot;
    tr[tot].sum=tr[tot].maxn=tr[tot].val=x;
    tr[tot].pri=rng();
    tr[tot].rev=tr[tot].add=tr[tot].ls=tr[tot].rs=0;
    tr[tot].sz=1;
    return tot;
}
void pushup(int p)
{
    tr[p].sum=tr[tr[p].ls].sum+tr[tr[p].rs].sum+tr[p].val;
    tr[p].maxn=tr[p].val;
    if(tr[p].ls)tr[p].maxn=max(tr[p].maxn,tr[tr[p].ls].maxn);
    if(tr[p].rs)tr[p].maxn=max(tr[p].maxn,tr[tr[p].rs].maxn);
    tr[p].sz=tr[tr[p].ls].sz+tr[tr[p].rs].sz+1;
}
void addtag(int p,int d)
{
    tr[p].val+=d;
    tr[p].add+=d;
    tr[p].sum+=tr[p].sz*d;
    tr[p].maxn+=d;
}
void pushdown(int p)
{
    if(tr[p].rev)
    {
        swap(tr[p].ls,tr[p].rs);
        if(tr[p].ls)tr[tr[p].ls].rev^=1;
        if(tr[p].rs)tr[tr[p].rs].rev^=1;
        tr[p].rev=0;
    }
    if(tr[p].add)
    {
        if(tr[p].ls)addtag(tr[p].ls,tr[p].add);
        if(tr[p].rs)addtag(tr[p].rs,tr[p].add);
        tr[p].add=0;
    }   
}
void split(int p,int k,int &L,int &R)
{
    if(!p)
    {
        L=R=0;
        return ;
    }
    pushdown(p);
    if(tr[tr[p].ls].sz<k)
    {
        L=p;
        split(tr[p].rs,k-tr[tr[p].ls].sz-1,tr[p].rs,R);
    }
    else
    {
        R=p;
        split(tr[p].ls,k,L,tr[p].ls);
    }
    pushup(p);
}
int merge(int L,int R)
{
    if(!L||!R)
        return L|R;
    if(tr[L].pri<=tr[R].pri)
    {
        pushdown(L);
        tr[L].rs=merge(tr[L].rs,R);
        pushup(L);
        return L;
    }
    pushdown(R);
    tr[R].ls=merge(L,tr[R].ls);
    pushup(R);
    return R;
}
void REVERSE(int l,int r)
{
    int L,R,p; 
    split(root,l-1,L,R);
    split(R,r-l+1,R,p);
    tr[R].rev^=1;
    root=merge(L,merge(R,p)); 
}
void ADD(int l,int r,int d)
{
    int L,R,p;
    split(root,l-1,L,R);
    split(R,r-l+1,R,p);
    addtag(R,d);
    root=merge(L,merge(R,p));
}
int GETSUM(int l,int r)
{
    int L,R,p;
    split(root,l-1,L,R);
    split(R,r-l+1,R,p);
    int res=tr[R].sum;
    root=merge(L,merge(R,p));
    return res;
} 
int GETMAX(int l,int r)
{
    int L,R,p;
    split(root,l-1,L,R);
    split(R,r-l+1,R,p);
    int res=tr[R].maxn;
    root=merge(L,merge(R,p));
    return res;
}
signed main()
{
    int x,y;
    cin>>x>>y;
    for(int i=1;i<=4;++i)
        root=merge(root,New(0));
    ADD(1,2,x);
    ADD(3,4,y);
    REVERSE(1,2);
    REVERSE(3,4);
    cout<<GETSUM(1,2)-GETMAX(1,2)+GETSUM(3,4)-GETMAX(3,4);
}```

上一页 | 下一页