fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. class A{
  5. interface G{long[]P(int n,int t,int s);}
  6. public static void main (String[] args){
  7. G J=(n,t,s)->{int[]W=new int[t-1];for(int i=0;i<t-1;i++){W[i]=new java.util.Random().nextInt(251);};long[]O=new long[n];for(int i=1;i<=n;i++){long T=0;for(int h=1;h<t;h++){T+=W[h-1]*Math.pow(i,h);}O[i-1]=((T+s)%251);}return O;};
  8. Scanner R=new Scanner(System.in);
  9. while(R.hasNextLine()){
  10. System.out.println(Arrays.toString(J.P(R.nextInt(),R.nextInt(),R.nextInt()))+'\n');
  11. }
  12. }
  13. }
Success #stdin #stdout 0.26s 321536KB
stdin
19 2 12
6 3 15
5 4 7
2 2 212
4 3 56
9 5 34
stdout
[66, 120, 174, 228, 31, 85, 139, 193, 247, 50, 104, 158, 212, 15, 69, 123, 177, 231, 34]

[219, 245, 93, 14, 8, 75]

[169, 83, 228, 79, 115]

[180, 148]

[115, 183, 9, 95]

[11, 45, 152, 79, 57, 48, 247, 78, 202]