Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX 2147483647
- #define GENUP(GEN,AMT) \
- long update_ ## GEN (){ \
- GEN=(GEN*AMT)%MAX;return GEN;}
- #define GENUP2(GEN, MODF) \
- long update_ ## GEN ## 2 (){ \
- do{update_ ## GEN ();}while((GEN%MODF)!=0); \
- return GEN;}
- long ga,gb;
- GENUP(ga, 16807)
- GENUP(gb, 48271)
- GENUP2(ga, 4)
- GENUP2(gb, 8)
- int compare_gens(long (*ua)(), long (*ub)()){
- long int a=(*ua)();
- long int b=(*ub)();
- return (a&0xFFFF)==(b&0xFFFF);
- }
- int judge(int iters, long (*ua)(), long (*ub)()){
- ga=703;gb=516;
- int count = 0;
- for(int i=0;i<iters;i++)
- count+=compare_gens(ua, ub);
- return count;
- }
- int main(){
- printf("%d\n", judge(40000000, &update_ga, &update_gb));
- printf("%d\n", judge(5000000, &update_ga2, &update_gb2));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement