|
|
back to board128*1024 size of memory???? why should i declare 128*1024 size of memory for 256KB described in the problem? my code goes here: #include<iostream> #include <cstdio> #include <cmath> double buf[128 * 1024]; int main() { int i = 0; unsigned long long n; while (scanf("%llu", &n) != EOF) { buf[i ++] = (double)sqrt(n * 1.0); } for (; --i >= 0; ) { printf("%.4lf\n", buf[i]); } return 0; } // why 128*1024 ? Re: 128*1024 size of memory???? Because 256kb means there's at most 128kb of digits and 128kb of spaces? Re: 128*1024 size of memory???? Here the array size is 128*1024 and it is double. So doesn't the array hold 128*1024*8 KB of memory(8 bytes for each element) ? Re: 128*1024 size of memory???? Well you don't necessarily need double, you may use long long int for keeping numbers. Of course, it's 8 bytes either way, but you just don't know whether your numbers are going to be a few huge ones, or a ton of 1-digit ones, so you just have to be on a safe side. |
|
|