summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-03 20:25:39 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-03 20:25:39 +0200
commita2e922d6a3f53baf9c15faf6152ed04da84386c4 (patch)
tree481140bf642721c9748a584016d86477f9c7d94a
parent6a967f763e620350f1938194323ca1e8abfda1b6 (diff)
downloadct_sequence-a2e922d6a3f53baf9c15faf6152ed04da84386c4.tar.gz
ok
-rw-r--r--src/main.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/main.c b/src/main.c
index 2d84279..5e7cff3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,53 +3,66 @@
#include <stdint.h>
#include <string.h>
-//#define MAX 100000000
-//#define MAX 5000000000
+typedef uint32_t uint_t;
+typedef int32_t int_t;
+#define BITS (sizeof(uint_t)*8)
-static void primt(uint64_t x,uint64_t t){
+static void primt(uint_t x,uint_t t){
//printf("%llu: %llu\n",x+1,t);
- printf("%llu\n",t);
+ printf("%u: %u\n",x+1,t);
+ //printf("%u\n",t);
}
int main(int argc,char **argv){
- uint64_t *h;
- uint64_t t;
- uint64_t max;
+ uint_t *h;
+ uint_t t;
+ uint_t max;
+ /*
if(argc < 2){
printf("usake: numper <num>\n");
return 1;
}
max = strtoull(argv[1],0,10);
- printf("%llu\n",max);
+ */
- //h = malloc(sizeof(uint32_t)*MAX);
- h = calloc(sizeof(uint64_t)*max,1);
+ max = 1000000000;
+
+ h = calloc(sizeof(uint_t)*max,1);
+ //h = malloc(sizeof(uint_t)*max);
if(!h){
printf("failed to allogate mamorY\n");
return 1;
}
- //memset(h,0xFF,sizeof(uint32_t)*MAX);
+ //memset(h,0xFF,sizeof(uint_t)*max);
t = 0;
- for(uint64_t x = 1;x < max;x++){
+ for(uint_t x = 1;x < max;x++){
/*
- if((int32_t)h[t] >= 0){
+ if((int32int_t)h[t] >= 0){
n = x-h[t];
}else{
n = 0;
}
*/
- uint64_t z;
- uint64_t ht;
+ uint_t z;
+ uint_t ht;
ht = h[t];
- z = (int64_t)ht>>63;
+ z = (int_t)ht>>(BITS-1);
h[t] = -x;
t = z & (x+ht);
+
+ /*
+ uint_t ht;
+ ht = h[t];
+ h[t] = x;
+ //t = ht == (uint_t)-1 ? 0 : x-ht;
+ t = (int_t)ht < 0 ? 0 : x-ht;
+ */
}
primt(max-1,t);