关于出题

最近出了不少垃圾题,开个地方存下自己的出题程序。

数据生成

#define others
#ifdef poj
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#endif // poj
#ifdef others
#include <bits/stdc++.h>
#endif // others
//#define file
#define all(x) x.begin(), x.end()
using namespace std;
const double eps = 1e-8;
int dcmp(double x) { if(fabs(x)<=eps) return 0; return (x>0)?1:-1;};
typedef long long LL;
typedef unsigned long long ULL;

void file() {
//    freopen("in.txt", "r", stdin);
    freopen("data_in.txt", "w", stdout);
}

LL trand(LL x, LL y) {
    return 1LL*rand()*rand()*rand()%(y-x+1) + x;
}

void gao(int n) {
    cout<<n<<endl;
    for(int i = 1; i <= n; i++)
        printf("%lld ", trand(1, 1000000000));
    puts("");
}

int main() {
    file();
    srand(19260817);
    cout<<10<<endl;
    gao(100000);
    gao(100000);
    gao(100000);
    gao(100000);
    gao(100000);
    gao(100000);
    gao(100000);
    gao(100000);
    gao(100000);
    gao(1000000);
    return 0;
}

生成均匀数据


  std::uniform_int_distribution<int> dis1(0, 100);  
  std::uniform_real_distribution<double> dis2(0.0, 1.0);  

暴力

#define others
#ifdef poj
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#endif // poj
#ifdef others
#include <bits/stdc++.h>
#endif // others
//#define file
#define all(x) x.begin(), x.end()
using namespace std;
#define eps 1e-8
const double pi = acos(-1.0);

typedef long long LL;
typedef unsigned long long ULL;
void umax(int &a, int b) {
    a = max(a, b);
}
void umin(int &a, int b) {
    a = min(a, b);
}
int dcmp(double x) {
    return fabs(x) <= eps?0:(x > 0?1:-1);
}
void file() {
    freopen("data_in.txt", "r", stdin);
    freopen("pai_out.txt", "w", stdout);
}

namespace solver {
    void solve() {

    }
};


int main() {
    file();
    int t;
    scanf("%d", &t);
    while(t--) solver::solve();
    return 0;
}

STD

#define others
#ifdef poj
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#endif // poj
#ifdef others
#include <bits/stdc++.h>
#endif // others
//#define file
#define all(x) x.begin(), x.end()
using namespace std;
#define eps 1e-8
const double pi = acos(-1.0);

typedef long long LL;
typedef unsigned long long ULL;
void umax(int &a, int b) {
    a = max(a, b);
}
void umin(int &a, int b) {
    a = min(a, b);
}
int dcmp(double x) {
    return fabs(x) <= eps?0:(x > 0?1:-1);
}
void file() {
    freopen("data_in.txt", "r", stdin);
    freopen("data_out.txt", "w", stdout);
}

namespace solver {
    typedef unsigned long long LL;
    void solve() {

    }
}

int main() {
    file();
    int t;
    scanf("%d", &t);
    while(t--)
        solver::solve();
    return 0;
}

构造n*n的概率矩阵

double v[111][111];

void gao(int x, int n) {
//    cout<<n<<endl;
    vector<int> G;
    map<int, int> mp;
    for(int i = 1; i < n; i++) {
        int v = rand() % (100 * n);
        while(mp.count(v))v = trand(1, 100*n);
        G.push_back(v);
        mp[v] = 1;
    }
    sort(all(G));
    int p = 0, cnt = 0;
    vector<double> res;
    for(int i = 0; i < G.size(); i++) {
        int val = G[i];
        while(p < val) {
            p++;
            cnt++;
        }
        res.push_back(1.0*cnt/(100*n));
        cnt = 0;
    }
    double sum = 0;
    res.push_back(1.0*(100*n-p) / (100*n));
    for(int i = 0; i < res.size(); i++)
        v[x][i] = res[i];
}

void gaogao(int n) {
    memset(v, 0, sizeof v);
    cout<<n<<endl;
    cout<<trand(2, n)<<endl;
    for(int i = 0; i < n; i++) {
        gao(i, n);
        v[i][(i+trand(1, n-1))%n] += v[i][i];
        v[i][i] = 0;
    }
    for(int i = 0; i < n; i++, puts(""))
        for(int j = 0; j < n; j++)
            cout<<v[i][j]<<' ';
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值