最近出了不少垃圾题,开个地方存下自己的出题程序。
数据生成
#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]<<' ';
}