summaryrefslogtreecommitdiff
path: root/euler29.c
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-05-24 21:39:58 +0800
committerIru Cai <mytbk920423@gmail.com>2018-05-24 21:39:58 +0800
commit1eefd58ca4fdb5d2f51f657bfd70c9a89a4707db (patch)
treeabde0e4da3c7fe138f3874a94d8eb7d0e44c3224 /euler29.c
downloadproject_euler-1eefd58ca4fdb5d2f51f657bfd70c9a89a4707db.tar.xz
initial commit
Diffstat (limited to 'euler29.c')
-rw-r--r--euler29.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/euler29.c b/euler29.c
new file mode 100644
index 0000000..a9e5fc5
--- /dev/null
+++ b/euler29.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#define LIMIT 4
+
+int d[LIMIT+1][LIMIT+1]={};
+int count=(LIMIT-1)*(LIMIT-1);
+
+int main()
+{
+ int a,b,c;
+ for (a=2;a<=LIMIT;a++){
+ int bb=a;
+ for (b=2;b<=LIMIT;b++){
+ bb*=a;
+ if (bb>LIMIT) break;
+ for (c=2;c<=LIMIT/b;c++){
+ d[bb][c]=1; // (a^b)^c = a^(bc)
+ }
+ }
+ }
+ for (a=2;a<=LIMIT;a++){
+ for (b=2;b<=LIMIT;b++){
+ if (d[a][b]){
+ printf("%d %d\n",a,b);
+ --count;
+ }
+ }
+ }
+ printf("%d\n",count);
+ return 0;
+}
+