Advertisement
Guest User

Day 15 Golf

a guest
Dec 15th, 2017
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #define GU(G,A) long u_##G(){G=(G*A)%2147483647;return G;}
  3. #define GU2(G,M) long u_##G##2 (){do{u_##G();}while((G%M)!=0);return G;}
  4. long a,b;GU(a,16807) GU(b,48271) GU2(a,4) GU2(b,8)
  5. int j(int iters, long (*ua)(), long (*ub)()){ a=703;b=516;int count = 0;
  6.     for(int i=0;i<iters;i++) count+=((*ua)()&0xFFFF)==((*ub)()&0xFFFF);
  7.     return count;}
  8. int main(){
  9.     printf("%d\n", j(40000000, &u_a, &u_b));
  10.     printf("%d\n", j(5000000, &u_a2, &u_b2));
  11.     return 0;}
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement