Submission #230426
Source Code Expand
#include <iostream> typedef struct _cl { struct _cl * next; struct _cl * prev; int cost; }cl ; typedef struct _head{ cl * head ; cl * tail ; }head ; int main(void) { int n = 0; int i = 0; int sum = 0 ; unsigned long long X = 0 ; unsigned long long Y = 0 ; head hd = {0} ; cl * list = NULL ; cl * prev = NULL ; std::cin >> n ; std::cin >> X ; list = (cl*)calloc(1, sizeof(cl)) ; std::cin >> list->cost ; hd.head = list ; hd.tail = list ; prev = list ; for(int i=1; i<n; ++i) { list = (cl*)calloc(1, sizeof(cl)) ; std::cin >> list->cost ; prev->next = list ; list->prev = prev ; prev = list ; hd.tail = list ; } Y=X ; list = hd.head ; while( Y ) { if ( Y & 0x1 ) { sum += list->cost ; } Y >>= 1 ; list = list->next ; } std::cout << sum << std::endl ; return 0 ; }
Submission Info
Submission Time | |
---|---|
Task | B - 価格の合計 |
User | amaga38 |
Language | C++ (G++ 4.6.4) |
Score | 0 |
Code Size | 883 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:29:34: error: ‘calloc’ was not declared in this scope