๐Ÿ“ฆ gopikrishna000 / templates-latest

๐Ÿ“„ narm.cpp ยท 29 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29<snippet>
	<content><![CDATA[


int narm(int x, int P) {
	if (-P <= x && x < (P << 1ll)) {
		if (x < 0) {
			x += P;
		}
		if (x >= P) {
			x -= P;
		}
		return x;
	}

	if (x < 0) {
		x += ((-x + P - 1) / P) * P;
	}
	return x % P;
}


]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>narm</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.c++</scope>
</snippet>