-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKsmallSumData.cpp
63 lines (58 loc) · 1.34 KB
/
KsmallSumData.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/***********************************************************
* @名称: K Smallest Sums 数据生成器
* @作者: Shawn
* @创建时间: 2017-12-12 21:19:03
* @修改人: Shawn
* @修改时间: 2017-12-12 21:19:03
* @备注:
* @题目来源:
***********************************************************/
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main()
{
ofstream fout("KsmallSums.in");
srand(time(NULL));
vector<long> data;
int n = 750;
int n1 = n * n;
long a = 1, b = 100000;
while (data.size() <= n1 )
{
while (data.size() < n1 * 2)
{
int result = rand() % (b - a + 1) + a;
data.push_back(result);
}
random_shuffle(data.begin(), data.end());
}
fout << n << '\n';
int count = 1;
int linecount = 0;
for (auto i = data.begin(); i != data.end(); ++i)
{
fout << *i << " ";
if (count % n == 0)
{
fout << '\n';
linecount++;
if(linecount==n)
{
break;
}
}
++count;
}
return 0;
}