Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import math,itertools as it
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1e10
I = map(int,raw_input().split())
for S,A,C in it.product(range(16),repeat=3):
R = S
O = [0]*M
for i in I:
R = (A*R+C)%M
O[(i+R)%M] += 1
tmp = -sum(1.0*x... | PYTHON |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define int long long // <-----!!!!!!!!!!!!!!!!!!!
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdli... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define M 256
#define EPS 1e-9
int main()
{
int N;
while(cin >> N, N){
int I[256];
for(int i = 0; i < N; i++) cin >> I[i];
double H = 1000000.0;
int S, A, C;
for(int s = 0; s <= 15; s++){
for(int a = 0; a <= 15; a++){
for(int c = 0; c ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1e10
l = map(int,raw_input().split())
ans = [0,0,0]
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*N
for i in range(N):
... | PYTHON |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<cmath>
#define EPS 1e-8
using namespace std;
double getEntropy(int s,int a,int c,int *l,int n){
double sum[256]={0};
double res=0;
int r=s;
for(int i=0;i<n;i++){
r=(a*r + c)&255;
sum[(r + l[i])&255]++;
}
for(int i=0;i<256;i++){
//cout << "sum["<<i<<"]:"<<sum[i] << e... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agent... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1e10
l = map(int,raw_input().split())
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*M
for i in range(N):
R = (A*R... | PYTHON |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1e10
l = map(int,raw_input().split())
ans = [0,0,0]
for S in range(16):
for A in range(16):
for C in range(16):
R = S
O = [0]*256
for i in range(N):
... | PYTHON |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define EPS 1e-9
#define M 256
#define INF 1e9
int main(){
int N;
while(cin >> N, N > 0){
int I[N+1],R[N+1],O[N+1];
for(int i = 0 ; i < N ; i++){
cin >> I[i];
}
int S,A,C;
double ans = INF;
for(int s = 0 ; s <= 15 ; s++){
for(int a... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | //57
#include<iostream>
#include<cmath>
using namespace std;
int main(){
for(int n;cin>>n,n;){
int l[256];
for(int i=0;i<n;i++){
cin>>l[i];
}
double me=1<<30;
int ms,ma,mc;
for(int s=0;s<16;s++){
for(int a=0;a<16;a++){
for(int c=0;c<16;c++){
int oa[256]={};
int r=s;
for... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<cmath>
using namespace std;
struct S{
double min;
int s, a, c;
};
int main(){
int N, l[257],r[257],o[257],x[257];
int s, a, c;
double H;
S ans;
while (1){
cin >> N;
if (N == 0) break;
for (int i = 1; i <= N; i++){
cin >> l[i];
}
for (s = 0; s <= 15; s++){
for (... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.util.*;
import static java.lang.System.*;
public class Main {
Scanner sc = new Scanner(in);
void run() {
int n;
int[][][][] R = new int[16][16][16][258];
for (int s = 0; s < 16; s++) {
for (int a = 0; a < 16; a++) {
for (int c = 0; c < 16; c++) {
R[s][a][c][0] = s;
for (int i = ... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
int I[555];
int S,A,C;
const int mod = 256;
int r[555];
int R(int i)
{
if(i==0)return r[i]=S;
return r[i]=(A*R(i-1)+C)%mod;
}
int main(void)
{
typedef long double ldouble;
for(;;) {
scanf("%d",&n); if(!n) break;
for(... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<math.h>
using namespace std;
int in[300], R[300], out[300];
const int M=256;
int cnt[300];
const double eps=1e-9;
int s, a, c;
void hoge(int N){
for(int i=1; i<=N; i++) cin>> in[i];
double h=10000000;
for(int S=0; S<=15; S++){
R[0]=S;
for(int A=0; A<=15; A++){
... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <set>
#include <cmath>
using namespace std;
int I[256];
int N;
double func(int S,int A,int C){
int R[256] = {};
R[0] = S;
for(int i = 1 ; i < 256 ; i++){
R[i] = (A*R[i-1]+C)... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n;
while (cin >> n, n) {
vector<int> l(n);
for (int i = 0; i < n; i++) {
cin >> l[i];
}
const int mod = 256;
int anss = 16, ansa = 16, ansc = 16;
double minh = 1e9;
for (int s = 0; s < 16; s++) {
for (int a... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
double entropy(int N, const vector<int> &x) {
double H = 0;
for (int i=0; i<256; ++i) {
if (x[i] != 0) {
H -= (double)x[i] / N * log((double)x[i] / N);
}
}
return H;
}
int main() ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int n;
vector<int> make_R(int s,int a,int c) {
vector<int> R(n+1);
R[0] = s;
for(int i=1; i<=n; ++i) R[i] = (a*R[i-1]+c)%256;
return R;
}
vector<int> make_O(vector<int> &I,vector<int> &R) ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
const double eps = 1e-8;
int s,a,c;
double... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
static const double INF = 1E20;
const int M = 256;
int res[3];
int N;
int I[333];
int R[333], O[333];
double c[333];
int main(int argc, char *argv[])
{
while(cin >> N, N){
rep(i, N) cin >> I[i];
double H = INF;
rep(S,... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define m 256
const double eps=1e-8;
int main(){
while(1){
int n, input[m+1];
scanf(" %d", &n);
if(n==0) break;
for(int i=1; i<=n; ++i) scanf(" %d", &input[i]);
int as=-1, aa=-1, ac=-1;
double minh=100000... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2165
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import math
M = 256
def entropy_if_smallest(ctr,bound):
ret = 0
for v in ctr:
if v == 0: continue
ret -= (v / N) * math.log2(v / N)
if ret >= bound:
return None
return ret
def solve(src):
ans_h = float('inf')
ans = None
for s in range(16):
for a in r... | PYTHON3 |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.util.Scanner;
public class Main
{
public void solve()
{
Scanner cin = new Scanner(System.in);
while(true)
{
int M = 256;
int N = cin.nextInt();
if(N == 0)break;
int[] L = new int[N];
for(int i = 0;i < N;i++)
{
L[i] = cin.nextInt();
}
int S = 0,A = 0,C = 0;
double minH ... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <cmath>
#include <iostream>
using namespace std;
int n, a[256];
int main() {
while (cin >> n, n) {
for (int i = 0; i < n; i++) cin >> a[i];
int mi, mj, mk; long double v = 1e+300L;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
for (int k = 0; k < 16; k++) {
int b[257] = { 0 }... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 |
import java.util.*;
import java.io.*;
public class Main{
static final Reader sc = new Reader();
static final PrintWriter out = new PrintWriter(System.out,false);
public static void main(String[] args) throws Exception {
while(true){
int n = sc.nextInt();
if(n==0){
break;
... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF... | PYTHON3 |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int M = 256;
int n, I[M];
long double calc(int S, int A, int C){
int r = S, cnt[M];
fill(cnt, cnt+M, 0);
for(int i=0;i<n;i++){
r = (A * r + C) % M;
cnt[(I[i] + r) % M]++;
}
long double res = 0.0;
for(int i=0;i<M... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#define rep(i, e) for( int i = 0; i < e; i++ )
#define eps 1e-10
typedef vector<int> vec;
int main(){
int N, M = 256;
while( cin >> N, N){
vec I(N);
rep(i, N) cin >> I[i];
int S, A, C;
double H = 10000... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
const double EPS = 1e-9;
const int MOD = 256;
int I[257];
int R[257];
int O[257];
int main() {
int N;
while (cin >> N && N) {
for (int i = 1; i <= N; i++) {
cin >> I[i];
}
int ansS, ansA, ansC;
double ansH = 100000000.0;
f... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
using namespace std;
#define ll long long
#d... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#includ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
constexpr double EPS = 1e-6;
constexpr int M = 256;
int S, A, C;
int R() {
return S = (A * S + C) % M;
}
int main() {
int N;
while(cin >> N, N) {
double H = 1e9;
int ret_s=1e9, ret_a=1e9, ret_c=1e9... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
const double INF = (double)(1 << 28);
const int MOD = 256;
const double EPS = 1e-10;
int main () {
int n;
while (cin >> n, n) {
vector<int> I(n);
for (auto &i : I) cin >> i;
double H = INF;
int S, A, C;
for (int s = 0; s <... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<cmath>
using namespace std;
#define M 256
int I[M+1];
int R[M+1];
int O[M+1];
int N;
long double getEntropy( int S, int A, int C ){
R[0] = S;
for ( int i = 1; i <= N; i++ ){
R[i] = (A*R[i-1]+C)%M;
}
for ( int i = 1; i <= N; i++ ){
O[i] = (I[i] + R[i])%M;
}
long d... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define M 256
const double infty = 1e40;
bool eq(double a, double b){
return abs(b-a) < 1e-9;
}
int main()
{
while(true){
int n;
cin >> n;
if( n == 0 ) break;
vector<int> ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
public class Main {
static FastScanner sc = new FastScanner();
public static void main(String[] args) throws Exception {
int[] hist = new int[256];
while (true) {
int ... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agent... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.util.*;
import java.math.*;
public class Main{
private static int S,A,C;
private static int[] I, Rmemo;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
if(n == 0) break;
I = new int[n];
for(int i=0;i<n;i++) I[i] = sc.next... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define int long long // <-----!!!!!!!!!!!!!!!!!!!
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;
int main(){
int n;
while(cin >> n, n){
int s, a... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n;
while(cin>>n,n){
int a[n],a1,a2,a3;
double mi=0;
r(i,n)cin>>a[i];
r(i,16)r(j,16)r(k,16){
int R=i,b[256]={};
r(l,n){
R=(j*R+k)%256;
b[(a[l]+R)%256]++;
}
double h... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
int n;
int T[1024];
int E[1024];
int main() {
for(;;) {
scanf("%d", &n);
if( n == 0 ) break;
for(int i = 0; i < n; ++i) {
scanf("%d", &E[i]);
}
double bH = 1e10;
int bS, bA, bC;
for(int S = 0; S < 16; ++S) {
for(int A = 0; A < 16; ++A) {
for(... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <math.h>
using namespace std;
typedef long long ll;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int mod=256;
while(1){
int n; cin >> n;
if(n==0)break;
vector<int... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<cstdio>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n,l[256],x,y,z;
while(scanf("%d",&n),n){
rep(i,n)scanf("%d",&l[i]);
double m = 1e9;
rep(s,16)rep(a,16)rep(c,16){
int u[256] = {0};
int r = s;
rep(i,n){
r = (a*r + c... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;
public class Main {
static final Scanner in = new Scanner(System.in);
static final PrintWriter out = new PrintWriter(System.out,false);
static boolean debug = false;
static boolean solve() {
int n = in.nextInt();
if (n == 0) re... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 |
import java.util.*;
import static java.lang.System.*;
class Main {
public static Scanner sc = new Scanner(in);
public static Random rand=new Random();
int m=256;
double EPS=1E-6;
public void run() {
while(true){
int N=sc.nextInt();
if(N==0)return;
int[] l=nextIntArray(N);
double resh=Double.MA... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<bits/stdc++.h>
#define N 257
#define M 256
using namespace std;
typedef pair<double,int> P0;
typedef pair<int,int> P1;
typedef pair<P0,P1> P;
int main(){
int n,l[N],R[N],O[N],cnt[N];
double H;
vector<P> v;
while(1){
cin>>n;
if(!n)break;
for(int i=1;i<=n;i++)cin>>l[i];
for(int S=0;S<16;... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
inline bool chmin(double &a, double b){
if (a - 1e-8 > b){
a = b;
return true;
}
return false;
}
const int M = 256;
int N;
int I[257], R[257], O[257];
int cnt[257];
double calc(int s, int a, int c)
{
R[0] = s;
for (int i = 1; i <= N; i++){
R[i] = (a * R[i - 1]... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define EPS 1e-10
int main() {
int n;
while (cin >> n, n) {
vector<int> I(n);
for (auto& a : I) cin >> a;
int s, a, c;
double h = 1e18;
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
for (int k = 0; k < 16; ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>
using namespace std;
typedef long long ll;
type... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define MOD 1000000007
#define EPS 1e-6
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int INF = 10000;
int main(){
while (1){
int N;
cin >> N;
if (N == 0){
break;
}
vector<int> l(N);
for (int i = 0; i < N; i++){
cin >> l[i];
}
double m = INF;
int s, a, c;
for (int S = 0; S < 16; S++){
for (int A = 0... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
// TODO θͺεηζγγγγ‘γ½γγγ»γΉγΏγ
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true){
... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
public class Main {
static FastScanner sc = new FastScanner();
public static void main(String[] args) throws Exception{
int[] hist = new int[256];
while (true) {
int N... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <tuple>
#include <numeric>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const double eps = 1e-8, inf = 1e8;
const int M = 256;
int N;
tuple<int, int, int> solve(vector<int>& Is){
int S = 0, A... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <cmath>
#include <iostream>
using namespace std;
int n, a[261], b[261];
int main() {
while (cin >> n, n) {
for (int i = 0; i < n; i++) cin >> a[i];
int mi, mj, mk; double v = 1e+300;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
for (int k = 0; k < 16; k++) {
int c[261] = { 0... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#de... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
using namespace std;
#define pi 3.1415926... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 256
#define EPS 1e-8
using namespace std;
typedef long long ll;
int main()
{
int n;
while(cin >> n && n) {... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 |
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;
#de... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define FOR(i,k,n) for(int i=(k); i<(int)(n);... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
constexpr double eps = 1e-10;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
while (cin >> n, n) {
vector<int> a(n);
for (auto&& e : a) {
cin >> e;
}
double mn = numeric_limits<double>::max();
int rs = -1, rp = -1, rq ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define FOR(i,k,n) for(int i=(k); i<(int)(n);... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const int M = 256;
const double epsilon = 1e-9;
int main() {
int N;
while (cin >> N && N) {
vector<int> L;
for (auto i=0; i<N; i++) {
int l;
cin >> l;
L.push_back(l);
}
double minH = ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int R[260], I[260], O[260];
int s, a, c, n, m = 256;
int ans[3];
double H, min_H;
int main(void){
int i, j;
while(cin >> n, n){
for(i = 1; i <= n; i++) cin >> I[i];
min_H = 100;
for(s = 0; s <= 15; s++){
for(a = 0; a <= 15; a++){... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
double entropy(int N, const vector<int> &x) {
double H = 0;
for (int i=0; i<256; ++i) {
if (x[i] != 0) {
H -= (double)x[i] / N * log((double)x[i] / N);
}
}
return H;
}
int main() ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cassert>
#include<iomanip>
#define M 256
#define MAX 257
#define EPS (1e-7)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;
int N;
int I[MAX],O[MAX],R[MAX];
int cnt[MAX];
void makeR(int S,int A,int C)
{
R[0] = S;
for(i... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
while(true){
int n;
cin >> n;
if(n == 0){ break; }
vector<int> v(n);
for(int i = 0; i < n; ++i){ cin >> v[i]; }
int best_s = 0, best_a = 0, best_c = 0;
double best_score = 1e20;
const int MOD = 256;
for(int s = ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
public class Main {
static FastScanner sc = new FastScanner();
public static void main(String[] args) throws Exception {
int[] I = new int[256];
double[] en = new double[257];
StringBuilder sb ... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<map>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
const int DIV =256;
double calc(int S,int A,int C,int *I,int n){
int R[n+1];
int O[n];
map<int,int>M;
R[0]=S;
REP(i,1,n+1)R[i]=(A*R[i-1]+C)%DIV;
rep(i,n)O[i]=(I[i]+R[i+... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
#define M 256;
using namespace std;
typedef pair <int,int> P;
typedef pair <int,P> PP;
int main(){
while(1){
int n,l[258],R[258],O[258];
cin>>n;
if(!n)break;
for(int i=1;i<=n;i++)cin>>l[i];
double ans=1e9;
PP SAC;
for(int s=0;s<=15;s++)
for(int a=0;a<=... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define FOR(i,k,n) for(int i=(k); i<(int)(n);... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define FOR(i,k,n) for(int i=(k); i<(int)(n);... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(void){
while (1) {
int N;
cin >> N;
if (N == 0) break;
int l[N];
for (int i = 0; i < N; i++) cin >> l[i];
double H = 1e10;
int s,a,c;
for (int S = 0; S < 16;... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<bits/stdc++.h>
#define MOD 256
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
int I[256];
int main() {
int n;
while (scanf("%d", &n), n) {
rep(i, n)scanf("%d", &I[i]);
int S, A, C;
double Min = INFINITY;
rep(s, 16)rep(a, 16)rep(c, 16) {
int r = s;
int mp[256]{};
rep(i, n) {
... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>
#define V... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double>... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;
int n;
int M = 256;
ld entropy(const vector<int> &v)
{
ld sum = 0;
map<int, ld> mp;... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bit... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
static const double EPS = 1e-9;
static const int MOD = 256;
int I[257];
int R[257];
int O[257];
int main(){
int N;
while(cin >> N && N){
for(int i = 1; i <= N; i++){
cin >> I[i];
}
int ansS, ansA, ansC;
doubl... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<bits/stdc++.h>
#define MOD 256
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
int I[256];
int main() {
int n;
while (scanf("%d", &n), n) {
rep(i, n)scanf("%d", &I[i]);
int S, A, C;
double Min = INFINITY;
rep(s, 16)rep(a, 16)rep(c, 16) {
int r = s;
unordered_map<int, int>mp;
rep... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
public class Main {
static FastScanner sc = new FastScanner();
public static void main(String[] args) throws Exception {
int[] I = new int[256];
double[] en = new double[257];
StringBuilder sb ... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;
#define FOR(i,k,n) for(int i=(k); i<(int)(n);... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.beg... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;
int n, I[1 << 10], R[1 << 10], O[1 << 10], V[1 << 10];
vector<tuple<long double, int, int, int>>vec;
int main() {
while (true) {
cin >> n; vec.clear(); if (n == 0)break;
for (int i = 1; i <= n; i++) { cin >... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<cstdio>
#include<cmath>
#define R(i,n) for(int i=0;i<n;i++)
#define D double
using namespace std;
int main(){int n,l[256],x,y,z;while(scanf("%d",&n),n){R(i,n)scanf("%d",&l[i]);D m=1e9;R(s,16)R(a,16)R(c,16){int u[256]={0};int r=s;R(i,n){r = (a*r + c)&255;u[(r + l[i])&255]++;}D tmp=0;R(i,256)if(u[i]){tmp-=u[i]*l... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cmath>
using namespace std;
#define MOD (256)
const double eps = 1e-10;
int main(void)
{
int n;
while (cin >> n, n){
int I[n];
for (int i = 0; i < n; i++){
cin >> I[i];
}
double ent = 1 << 29;
int S = -1, A = -1, C = -1;
for (int s = 0; s < 16; s++){
for (int a = 0... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include "bits/stdc++.h"
#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;
#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)
int main(){
int n, o[256], in[256], x[256], s, a, c, r, ms, ma, mc;
double ans, ins;
while(1){
cin ... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 |
import java.util.*;
import java.lang.*;
import java.math.*;
public class Main {
Scanner sc = new Scanner(System.in);
void run() {
for (;;) {
int n = sc.nextInt();
if (n == 0) {
break;
}
int l[] = new int[n+1];
for (int i = 1; i < n+1; i++) {
l[i] = sc.nextInt();
}
... | JAVA |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | #include <iostream>
#include <cmath>
using namespace std;
int main() {
const int M = 256;
int N;
while (cin >> N && N) {
int I[256];
for (int i=1; i<=N; ++i) cin >> I[i];
double Hmin = 1000.0;
int s, a, c, upper = N;
for (int S=0; S<=15; ++S) {
for (int A=0; A<=15; ++A) {
for (int C=0; C<=15; ++C)... | CPP |
p01283 Strange String Manipulation | A linear congruential generator produces a series R(β
) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 β€ S, A, C β€ 15 and M = 256.
Now suppose we have some input string I(β
), where each character in the string is an integer between 0 and (M - ... | 7 | 0 | import math
def prodR(s,a,c,N):
R=[s]
for i in range(1,N+1):
R.append((a*R[i-1]+c)%256)
return R[1:]
def entropy(R,I,N):
O=[(I[i]+R[i])%256 for i in range(N)]
L=[0]*256
for i in O:
L[i]+=1
H=-sum(float(L[i])/N*math.log(float(L[i])/N,2) for i in range(256) if L[i]!=0)
ret... | PYTHON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.