Skip to content

Instantly share code, notes, and snippets.

@aximov
Created July 6, 2018 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aximov/540c1659e7cbe0d971fab1b4a1416362 to your computer and use it in GitHub Desktop.
Save aximov/540c1659e7cbe0d971fab1b4a1416362 to your computer and use it in GitHub Desktop.
合同法による乱数の発生
#include <bits/stdc++.h>
using namespace std;
int irand(int ir) {
int a = 5, c = 1, m = 16;
return (a * ir + c) % m;
}
int main() {
int r = 0;
for (int i = 0; i < 32; ++i) {
r = irand(r);
cout << r << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment