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 |
|---|---|---|---|---|---|
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,ans=0;
pair<int,int> a[10000];
while(1){
ans=0;
cin>>n>>m;
if(n==0 && m==0) break;
for(int i=0;i<n;i++){
cin>>a[i].second>>a[i].first;
}
sort(a,a+n);
for(int i=n-1;i>=0;i--){
if(a[i].second<m) m-=a[i].seco... | CPP |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | while 1:
n,m= list(map(int,input().split(' ')))
if n == m ==0:break
D = []
for _ in range(n):
d_i,p_i = list(map(int,input().split(' ')))
D.append((d_i,p_i))
D = sorted(D,key = lambda x:x[1],reverse = True)
while m > 0:
if len(D) ==0:break
temp = D.pop(0)
... | PYTHON3 |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
int main(){
int N,M;
while(1){
cin >>N>>M;
if(N==0 && M==0)break;
P a[N];
for(int i=0 ; i < N ; i++){
cin >>a[i].second>>a[i].first;
}
sort(a,a+N,greater<P>());
for(int i=0 ; i < N ; i++){
i... | CPP |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | while True:
n,m = map(int,input().split())
if n==0: break
dp = [list(map(int,input().split())) for _ in range(n)]
dp.sort(key=lambda x:x[1],reverse=True)
sm = 0
for d,p in dp:
d,m = [d-m, 0] if d>m else [0, m-d]
if m==0: sm += d*p
print(sm) | PYTHON3 |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | while 1:
n,m=map(int,input().split())
a=[]
if n==0:break
for _ in range(n):
d,p=map(int,input().split())
a.append([p,d])
a.sort(reverse=1)
b=0
for p,d in a:
if d<=m:
m-=d
else:
b+=p*(d-m)
m=0
print(b) | PYTHON3 |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
class Main {
private static void solve() {
final Scanner scanner = new Scanner(System.in);
while (true) {
final int n = scanner.nextInt();
final int m = scanner.nextInt();
if (n == 0... | JAVA |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> P; //p, d
int n, m;
P pd[10000];
signed main() {
int i;
while (cin >> n >> m) {
if (!n) break;
for (i = 0; i < n; i++) cin >> pd[i].second >> pd[i].first;
sort(pd, pd + n, greater<P>(... | CPP |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include <algorithm>
#include <utility>
#include <iostream>
using namespace std;
int N, M, ans;
pair<int,int> PD[10010];
int main() {
while (cin >> N >> M && N) {
ans = 0;
int d, p, m;
m = M;
for (int i=0; i<N; ++i) {
cin >> d >> p;
PD[i] = make_pair(p, d);
}
sort(PD,PD+N);
for (int i=0; i<N; ++i... | CPP |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | while True:
N,M = map(int,input().split())
if N == 0: break
src = []
for i in range(N):
d,p = map(int,input().split())
src.append((p,d))
money = M
ans = 0
for p,d in sorted(src,reverse=True):
guard = min(d,money)
money -= guard
ans += (d - guard) * p
... | PYTHON3 |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
# define REP(i,n) for(int i=0; i<n;i++)
using namespace std;
int main(){
while(1){
long long int n, m, p, d, ans;
vector<pair<int,int> > pd;
cin >> n >> m;
if (n==0 && m==0) return 0;
ans = 0;
REP(i,n){
cin >> d >> p;
pd.push_back(make_... | CPP |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | n,m = map(int, input().split())
while(n != 0 or m != 0):
dplists = []
for i in range(n):
dplist= list(map(int, input().split()))
dplists.append(dplist)
dplists = sorted(dplists, key = lambda x: x[1], reverse = True)
for i in range(n):
if ( m >= dplists[i][0]):
m = m -... | PYTHON3 |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
int main(){
while(true){
int N, M;
cin >> N >> M;
if(N == 0 && M == 0){ break; }
vector<pii> r(N);
for(int i = 0; i < N; ++i){
cin >> r[i].second >> r[i].fir... | CPP |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | # AOJ2019
shukuba = []
n = 0
m = 0
def solve():
shukuba.sort(key = lambda x: x[1])
s = sum(map(lambda x: x[0], shukuba)) - m
if s <= 0:
return 0
e = 0
i = 0
while s > 0:
d = shukuba[i][0] if s >= shukuba[i][0] else s
e += shukuba[i][1] * d
s -= d
i += 1
... | PYTHON3 |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <map>
#include <functional>
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;
int main(){
int n,m;
while(cin >> n >> m,n||m){
P p[10000];
for(int i = 0; i < n; i++) cin >> p[i].sec >> p[i].fi;
sort(p,p+n,greater<P>());
for(int ... | CPP |
p01144 Princess's Marriage | Princess'Marriage
Marriage of a princess
English text is not available in this practice contest.
A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a result, he spent more money t... | 7 | 0 | #include<utility>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int n, m, i, p, s;
pair<int,int> w[10000];
while(cin >> n >> m && n)
{
for( i = 0; i < n; i++)
{
cin >> w[i].second >> w[i].first;
}
sort(w, w+n);
i=1;
while( i <= n )
{
if ((m -= w[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 <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limit... | 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 java.util.ArrayList;
import java.util.Scanner;
public class Main {
Scanner sc = new Scanner(System.in);
public void run() {
while(sc.hasNext()){
int n = sc.nextInt();
if(n == 0 )break;
else calc(n);
}
}
public void calc(int n){
int[] Is = new int[n];
for(int i = 0; i < n; i++){
Is[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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstr... | 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<pair<long double,int>>vec;
int main() {
while (true) {
cin >> n; vec.clear(); if (n == 0)break;
for (int i = 1; i <= n; i++) { cin >> I[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<cstdio>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define M 256
using namespace std;
int main(){
int n,l[M],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[M] = {0};
int r = s;
rep(i,n){
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 <algorithm>
#include <math.h>
#include <vector>
#include <string.h>
#include <cstdio>
#define M 256
int num[M]={0};
const double EPS = 1e-9;
using namespace std;
int main(void)
{
int s,a,c;
int n;
int R,O;
double H;
double mini;
int mins,mina,minc;
int i1,i2;
while(1){
cin>>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>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;
int r[16][16][16][260];
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<cmath>
using namespace std;
#define eps 0.0000000001
bool eq(double a,double b){
return ( -eps < a-b && a-b < eps );
}
int N;
int t[256];
double calc(int S,int A,int C){
int cnt[256]={};
int x=S;
for(int i=0;i<N;i++){
x=(A*x+C)%256;
cnt[(t[i]+x)%256]++;
}
double res=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 | #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#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 | import java.util.*;
public class Main {
private void doit(){
Scanner sc = new Scanner(System.in);
while(true){
int n = sc.nextInt();
if(n == 0) break;
int [] data = new int[n + 1];
for(int i = 1; i <= n; i++){
data[i] = sc.nextInt();
}
int m = 256;
double ans = 1 << 24;
int as=0, aa=... | 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 <string>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
double entropy(int N, const map<int,int> &x) {
double H = 0;
for (map<int,int>::const_iterator it=x.begin(); it!=x.end(); ++it) {
H -= (double)it->second / N * log((double)it->second / 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 <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;
int N;
void func(){
double minimum = (double)BIG_NUM,tmp;
int ans_S,ans_A,ans_C,M=256,R[N+1],input[N+1],O[N+1],check[256];
for(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];
int[][][][] table = ne... | 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 <cmath>
using namespace std;
#define EPS 1e-10
bool isequal(double a, double b)
{
return fabs(a-b) < EPS;
}
int N,I[256];
double calc(int S, int A, int C)
{
int R=S, cnt[256]={0};
for(int i=0; i<N; i++)
{
R=(A*R+C)%256;
cnt[(I[i]+R)%256]++;
}
double ret=0;
for(int i=0; i<256; ... | 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 int64;
int N;
vector< int > I;
int S, A, C;
int R(int i) {
if(i == 0) return(S);
return((A * R(i - 1) + C) % 256);
}
int O(int i) {
return((I[i - 1] + R(i)) % 256);
}
int main() {
while(cin >> N, N){
I.resize(N);
for(int 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 <vector>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;
int main(void) {
int N;
int M = 256;
cin >> N;
while ( N != 0 ) {
std::vector<int> I(N);
for (int i = 0; i < N; i++) {
cin >> I[i];
}
bool find = false;
int R,O;
int S,A,C;
int now;
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 | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
public class Main{
static PrintWriter out;
static InputReader ir;
static final double EPS=1e-10... | 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 <cmath>
#include <tuple>
using namespace std;
typedef tuple<int,int,int> T;
const int M = 256;
int main(){
int N;
while(cin>>N,N){
vector<int> I(N);
for(auto &i:I)cin>>i;
double entropy = 1e20;
int occur[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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <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 <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
const int m=256;
const int INF=1000000000;
int val[300];
int calc(int idx,int a,int c){
if(val[idx]!=INF)
return val[idx];
int res=(a*calc(idx-1,a,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;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#def... | 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.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
int[] I = new int[n];
int[] R = new int[n];
for (int i = 0; i < n; i++)
I[i] = sc.nextInt();
int S = 0, A = 0, C =... | 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 <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloa... | 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 pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}
int N;
int L[256],R[25... | 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 | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
usi... | 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 | ///
// File: 2165.cpp
// Author: ymiyamoto
//
// Created on Tue Nov 28 22:51:14 2017
//
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define EPS 1e-9
#define M 256
uint32_t R(uint32_t i, uint32_t S, uint32_t A, uint32_t C)
{
if (i == 0)
return ... | 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 <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define f first
#define s second
#define mp make_pair
inline int getInt(){ int s; scanf("%d", &s); return s; }
using namespace std;
int l[256];
int cnt[256];
int main(){
while(int n = getInt()){
... | 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 x[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 | 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 | import math
M = 256
while 1:
N = int(raw_input())
if N == 0: break
H = 1e10
I = 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 I:
R = (A*R+C)%M
... | 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 <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 "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int N;
int L[256],R[256],O[256];
int S,A,C;
double mi;
int main(){
while(cin>>N,N){
REP(i,N)cin>>L[i];
mi=1e9;
REP(s,16)REP(a,16)REP(c,16){
memset(O,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 <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-8;
const int M = 256;
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];
}
int ans[3]={0,0,0};
double minH = 1e18;... | 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 <cmath>
using namespace std;
const int M = 256;
const double EPS = 1e-9;
int n, I[M];
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]++;
}
double res = 0.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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstr... | 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 <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <stack>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace ... | 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 EPS 1e-9
using namespace std;
int S,A,C,N,M=256;
int l[257];
int u[257];
int main(){
int i,s,a,c;
double b;
while(1){
scanf("%d",&N);
if(!N){break;}
for(i=1;i<=N;i++){
scanf("%d",&l[i]);
}
double r=1e5;
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 <bits/stdc++.h>
using namespace std;
#define for_(i,a,b) for(int i=a;i<b;i++)
#define minit(a,b) memset(a,b,sizeof(a))
int N;
int l[300];
int MOD = 256;
int r[300], o[300];
void make_str(int S, int A, int C) {
minit(r,0); minit(o,0);
r[0] = (A*S + C) % MOD;
for_(i,1,N) r[i] = (A * r[i - 1] + C) % 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 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while (scanf("%d", &n) && n){
int I[257];
for (int i = 1; i <= n; i++) scanf("%d", I + i);
pair<int, pair<int, int> > res = make_pair(20, make_pair(20, 20));
double mini = 1e30;
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 <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=(0); i<n; ++i)
double eps = 1e-10;
const int INF = 1e+9;
typedef pair<int, int> P;
typedef pair<int, P> pp;
const int MAX_N = 105000;
int M = 256;
int N, I[512];
int main() {
while(cin >> N && N){
int S, A, C;
double minum = INF;
REP(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;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
double entoropy(vector<int> a, vector<int> b ){
vector<int> O(a.size());
rep(i,a.size()){
... | 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 <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include... | 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(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9+7
using namespace std;
typedef long double ld;
ld calc(int s, int a, int c, const vector<int> &in){
int r[260];
r[0] = s;
for(int i=1; i<260; i++){
r[i] = (a * r[i-1] + c) % 2... | 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 <math.h>
#include <map>
#define MAX_SAC 15
#define EPS 0.0000000001
using namespace std;
int main(int argc, char const *argv[])
{
int s,a,c;
int m=256;
int n;
int mins,mina,minc;
double min;
double h;
while(1){
cin>>n;
if(n==0) break;
vector<int> l(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 | import java.util.Scanner;
//Strange String Manipulation
public class Main{
void run(){
Scanner sc = new Scanner(System.in);
for(;;){
int n = sc.nextInt();
if(n==0)break;
double min = 1<<29;
int S = 0, A = 0, C = 0;
int[] I = new int[n];
for(int i=0;i<n;i++)I[i]=sc.nextInt();
for(int s=0;s<16... | 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;
int main(){
int n;
while(cin>>n,n){
int a[n],a1,a2,a3;
double mi=0;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<16;i++)
for(int j=0;j<16;j++)
for(int k=0;k<16;k++){
int R=i;
int b[256]={};
for(int l=0;l<n;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>
#include<cfloat>
using namespace std;
const double EPS = 0.00000001;
int main(){
int n;
while(cin >> n, n){
int str[n];
for(int i = 0; i < n; i++) cin >> str[i];
int x, y, z;
double score = DBL_MAX;
for(int s = 0; s <= 15; 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<bits/stdc++.h>
using namespace std;
const double EPS=1e-9;
int main(){
int n;
while(cin>>n,n){
int I[333],M=256;
for(int i=0;i<n;i++)cin>>I[i];
int as,aa,ac;
double ah=11111;
for(int S=0;S<16;S++)
for(int A=0;A<16;A++)
for(int C=0;C<16;C++){
int R=S;
int cnt[333]={};
for(int i=0;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 | import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class Main{
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
while(true){
final int N = 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<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=(1LL<<61)-1;
template<class T> inline bool chmin(T&... | 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<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000... | 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 <algorithm>
#include <cmath>
#include <math.h>
#define m 256
using namespace std;
int main(){
int n;
while(cin>>n){
if(n==0) break;
int ii[n+1],r[n+1],o[n+1];
for(int i=1;i<=n;i++){
cin>>ii[i];
}
int ss=16,aa=16,cc=16;
float h,mh=100;
for(int s=15;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 rep(i, n) for (int i = 0; i < int(n); ++i)
int R[16][16][16][300];
int main() {
rep (a, 16) rep (c, 16) rep (s, 16) {
R[a][c][s][0] = s;
rep (i, 256) {
R[a][c][s][i + 1] = (a * R[a][c][s][i] + c) % 256;
}
}
int n, I[300];
whil... | 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;
int main(){
int n;
while( cin >> n,n){
int I[256];
for(int i=0;i<n;i++) cin >> I[i];
double Hmin = -1;
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++){
double tmpH = 0.0;
int R = 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 <algorithm>
#include <cmath>
#include <vector>
using namespace std;
void solve(const int& n, const vector<int>& v) {
double minH = 1e25;
int bs, ba, bc;
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 | #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
using namespace std;
#define ... | 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 <cmath>
#include <set>
using namespace std;
const int M = 256;
int main()
{
while(1){
int N;
cin >> N;
if(N == 0) break;
int I[N+1];
for(int i = 1; i <= N; i++)
cin >> I[i];
int R[N+1], O[N+1], S, A, C;
double H = 1.0;
set<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;
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<cmath>
using namespace std;
int main()
{
int N,I[256],R[256],A,S,C,a,s,c,M=256,r;
double H,h,eps=1e-8;
while(1){
cin>>N;
if(N==0)break;
for(int i=0;i<N;i++)cin>>I[i];
H=10000000.0;
for(a=0;a<16;a++){
for(s=0;s<16;s++){
for(c=0;c<16;c++){
for(int i=0;i<M;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 <algorithm>
#include <cmath>
#include <math.h>
#define m 256
using namespace std;
int main(){
int n;
while(cin>>n){
if(n==0) break;
int ii[n+1],r[n+1],o[n+1];
for(int i=1;i<=n;i++){
cin>>ii[i];
}
int ss=16,aa=16,cc=16;
long long h,mh=10000000000000;
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 <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;
int N;
void func(){
double minimum = (double)BIG_NUM,tmp,bunbo=(double)N;
int ans_S,ans_A,ans_C,M=256,R[N+1],input[N+1],O[N+1],check... | 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.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
int N = sc.nextInt();
if (N == 0) break;
int[] I = new int[N];
for (int i = 0; i < N; ++i) {
I[i] = sc.nextInt();
}
double best = Double.MAX_VALU... | 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.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(true){
int N = sc.nextInt();
if(N==0)break;
int[] a = new int[N+1];
for (int i = 0; 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 |
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2165
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(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<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define... | 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 <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 | 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];
int[] I = new int[256]... | 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>
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<bits/stdc++.h>
using namespace std;
int main(){
int n;
const int M=256;
while(cin>>n,n){
vector<int> l(n);
for(int i=0;i<n;i++){
cin>>l[i];
}
double res=1e9;
int ress=-1;
int resa=-1;
int resc=-1;
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 | #include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
int main(){
int n;
while(cin >> n, n){
int I[256];
for(int i=0;i<n;i++) cin >> I[i];
double Hmin = -1;
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++){
double tmpH = 0.0;
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 <bits/stdc++.h>
using namespace std;
using ld = long double;
const int mod = 0xff;
const ld eps = 1e-10;
int main()
{
int N;
while (cin >> N, N) {
vector<int> I(N);
for (int i = 0; i < N; i++) {
cin >> I[i];
}
int rS = -1, rA = -1, rC = -1;
ld mH = 1e20;
for (int S = 0; S < 16; 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<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<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 <set>
#include <cmath>
using namespace std;
const int m=256;
int main()
{
int n,s,a,c,I[256],anss,ansa,ansc;
for(;;){
cin>>n;
if(!n) break;
for(int i=1;i<=n;i++)
cin>>I[i];
int max=n;
double min=100000.0;
for(s=0;s<=15;s++)
for(a=0;a<=15;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 <cmath>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
int N, M = 256;
while(cin >> N, N){
int l[N], s = -1, a = -1, c = -1;
long double H = (1e10);
for(int i = 0; i < N; ++i)
cin >> l[i];
for(int S = 0; S < 16; ++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<cmath>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
const double EPS = 1e-9;
struct Data{int S,A,C;};
vector<int> I;
int N;
void input(){
I.resize(N+1);
for(int i = 1; i <= N; i++) cin >> I[i];
}
double calc(int S, int A, int C){
vector<int> R(N+1),O(... | 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 LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,n) for(int i=(int)(n-1);i>=0;--i)
#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<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.be... | 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<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* 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;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> vi;
typedef vector<vi> vvi;
typed... | 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 reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
int main(){
int n;
const int mod=256;
while(cin>>n,n){
vector<int> v(n);
rep(i,n){
cin>>v[i];
}
vector<int> R(n+1);
vector<int> O(2... | 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 int ll;
vector<ll> a;
ll n;
ll mod=256;
const double EPS=1e-9;
double str(ll s,ll A,int c){
vector<ll> k(n+1);
vector<ll> C(256,0);
k[0]=s;
//C[(s+a[0])%mod]++;
for(int i=1;i<=n;i++){
k[i]=(k[i-1]*A+c)%mod;
C[(int)((k[i]+a[i-1])%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 | #include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int n;
int L[300],R[300];
double cnt[300];
int main()
{
while(cin>>n,n)
{
for(int i=0;i<n;i++)cin>>L[i];
int ansS,ansA,ansC;
double m=1e9;
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 | #include<iostream>
#include<cmath>
using namespace std;
int n, I[1 << 10], R[1 << 10], V[1 << 10];
int main() {
while (true) {
cin >> n; if (n == 0)break;
for (int i = 1; i <= n; i++) { cin >> I[i]; }
long double minx = 100.0; int T = 0;
for (int S = 0; S < 16; S++) {
for (int A = 0; A < 16; A++) {
for ... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.