/home/toolbox/public_html/solutions/12/1243/c.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <stdint.h>
9 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16 /* fprintf(stderr, "functionName: message", varslist); */
17
18 /*
19 * Author: Isaac Traxler
20 * Date: 2023-02-17
21 * Purpose: fun
22 * Problem: 1230 - Modex
23 */
24
25 /*
26 * This template reads data a specified number of times.
27 */
28
29 int numberOfTimes;
30 int x;
31 int y;
32 int n;
33
34 void init()
35 {
36 /* FUNCTION init */
37 scanf("%d ", &numberOfTimes);
38 } /* FUNCTION init */
39
40 void dump()
41 {
42 /* FUNCTION dump */
43 } /* FUNCTION dump */
44
45 void getInput()
46 {
47 /* FUNCTION getInput */
48 scanf(" %d %d %d ", &x, &y, &n);
49 } /* FUNCTION getInput */
50
51 void process()
52 {
53 /* FUNCTION process */
54 int i;
55 int cnt;
56 int tmp;
57
58 cnt = y % (n - 1);
59 tmp = x % n;
60 for (i=1; cnt>i; i++)
61 {
62 /* for */
63 printf("(tmp %d) (tmp * %d %d) (i %d) (cnt %d)\n", tmp, x, tmp*x, i, cnt);
64 tmp = (tmp * x) % n;
65 } /* for */
66 printf("%d\n", tmp);
67 } /* FUNCTION process */
68
69 int main()
70 {
71 /* main */
72 int i;
73
74 init();
75 for (i=0; i<numberOfTimes; i++)
76 {
77 /* while */
78 getInput();
79 process();
80 } /* while */
81
82 return EXIT_SUCCESS;
83 } /* main */
84
85