ARRAY getarray() { ARRAY array; float sz = 0, ctr = 0; int i; FILE *fin = fopen("in.txt", "r"); while(fgetc(fin) != EOF) sz++; printf("\nInput process's number, from 1 to %.0f: ",sz); array.size = sz; array.num = scani(sz); array.ar = (int *)calloc(array.num, sizeof(int)); for(i = array.num; i > 0; i--) { ctr = sz/i; if(sz - ceil(ctr) >= 0) ctr = ceil(ctr); array.ar[array.num - i] = ctr; sz -= ctr; } fclose(fin); return array; }
int main() { int t=scani(); matrix A; A.a1=1; A.a2=1; A.a3=1; A.a4=0; while(t--) { ll n=scanll(); //scanf("%lld",&n); if(n==0) { printf("0\n"); continue; } if(n==1) { printf("2\n"); continue; } matrix tmp=expo(A,n); printf("%lld\n",(powder2N(tmp.a2))%MOD); } return 0; }
// mon_decodecmd() static void mon_decodecmd() { char* s; int adr; int len; int val; char fname[32]; switch (rxbuf[0]) { case 'h': // help if (rxbuf[1]==0 || rxbuf[1]=='\n' || rxbuf[1]=='\r') { mon_usage(); } else mon_illcmd(); break; case 'r': // reboot if (rxbuf[1]==0 || rxbuf[1]=='\n' || rxbuf[1]=='\r') { RST_system(); } else mon_illcmd(); break; case 'e': // exit mon if (rxbuf[1]==0 || rxbuf[1]=='\n' || rxbuf[1]=='\r') { rxwp = rxrp = txwp = txrp = txln = 0; mon_step = 0; mon_en = 0; } else mon_illcmd(); break; case 'c': // ctrl read/write if (rxbuf[1] == 'w') { // write if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;} scani(s, &adr); adr = adr&0xfffffffc; if ( (s = next_word(s)) == NULL ) { mon_illcmd(); break;} scani(s, &val); write32(adr, val); rxwp = 0; } else if (rxbuf[1] == 'r') { // read if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;} scani(s, &adr); adr = adr&0xfffffffc; val = read32(adr); sprintf(stbuf, "0x%8x = 0x%8x (b%32b)\r\n", adr, val, val); txbuf_puts(stbuf); rxwp = 0; } else mon_illcmd(); break; case 'a': // amiga read/write if (rxbuf[1] == 'w') { // write if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;} scani(s, &adr); adr = adr&0xfffffffc; if ( (s = next_word(s)) == NULL ) { mon_illcmd(); break;} scani(s, &val); EnableOsd(); rstval = rstval | SPI_CPU_HLT; SPI(rstval); DisableOsd(); MEM_UPLOAD_INIT(adr); MEM_WRITE16(val); MEM_UPLOAD_FINI(); EnableOsd(); rstval = rstval & ~SPI_CPU_HLT; SPI(rstval); DisableOsd(); rxwp = 0; } else if (rxbuf[1] == 'r') { // read printf("Amiga mem read currently unimplemented.\r"); rxwp = 0; } else mon_illcmd(); break; case 'u': // file upload if ((s = next_word(rxbuf)) == NULL) { mon_illcmd(); break;} //scani(s, fname); printf("File upload currently unimplemented.\r"); rxwp = 0; break; } }