View difference between Paste ID: SzpzyPQH and TeXWsi7c
SHOW: | | - or go back to the newest paste.
1-
RG Code:
1+
Code:
2-
00000001
2+
#include<iostream>
3-
00000002
3+
#include<stdio.h>
4-
00000003
4+
using namespace std;
5-
00000004
5+
int power(int n, int i)
6-
00000005
6+
{
7-
00000011
7+
	if(i==0) return 1;
8-
00000022
8+
	else return n*power(n,i-1);
9-
00000033
9+
}
10-
00000044
10+
11-
00000055
11+
void assigndectohex(int*a, int n)
12-
00000101
12+
{
13-
00000202
13+
	for(int i=7;i>=0;i--)
14-
00000303
14+
	{
15-
00000404
15+
		a[i]=n%6;
16-
00000505
16+
		n=n/6;
17-
00001111
17+
	}
18-
00002222
18+
}
19-
00003333
19+
20-
00004444
20+
int hextodec(int*a)
21-
00005555
21+
{
22-
00010001
22+
	int n=0;
23-
00020002
23+
	for(int i=0;i<8;i++)
24-
00030003
24+
		n=n+a[i]*power(6,i);
25-
00040004
25+
	return n;
26-
00050005
26+
}
27-
00110011
27+
28-
00220022
28+
int main()
29-
00330033
29+
{
30-
00440044
30+
	FILE*fp=fopen("omo39out.txt","w");
31-
00550055
31+
	int a[8][8], flag,count;
32-
01010101
32+
	for(int n=1;n<=1679615;n++)
33-
02020202
33+
	{
34-
03030303
34+
		flag=1;
35-
04040404
35+
		assigndectohex(a[0],n);
36-
05050505
36+
		for(int i=1;i<8;i++)
37
		{
38
			for(int j=0;j<8;j++)
39
			{
40
				a[i][(j+7)%8]=a[i-1][j];
41-
55555555
41+
			}
42-
40
42+
		}
43
		
44-
SM Code: 
44+
		for(int i=1;i<8;i++)
45
		{
46
			if((hextodec(a[i])%hextodec(a[0]))!=0)
47
			{
48
				flag=0; break;
49
			}
50
		}
51
		
52
		if(flag==1)
53
		{
54
			count++;
55
			for(int i=0;i<8;i++)
56
			{fprintf(fp,"%d", a[0][i]);}
57
			fprintf(fp,"\n");
58
		}
59
	}
60
	fclose(fp);
61
	printf("So count of such numbers=%d",count);
62
	return 0;
63
}
64
//Output:
65
10000000
66
10001000
67
10100000
68
10101010
69
11000000
70
11001100
71
11110000
72
11111111
73
20000000
74
20002000
75
20200000
76
20202020
77
22000000
78
22002200
79
22220000
80
22222222
81
30000000
82
30003000
83
30300000
84
30303030
85
33000000
86
33003300
87
33330000
88
33333333
89
40000000
90
40004000
91
40400000
92
40404040
93
44000000
94
44004400
95
44440000
96
44444444
97
50000000
98
50005000
99
50500000
100
50505050
101
55000000
102
55005500
103
55550000
104
46