Skip to content

Instantly share code, notes, and snippets.

@vikhyat
Created December 10, 2014 05:04
Show Gist options
  • Save vikhyat/bece755992a5d1b47e5a to your computer and use it in GitHub Desktop.
Save vikhyat/bece755992a5d1b47e5a to your computer and use it in GitHub Desktop.
#define classify(x) (((x) >= 0.5) ? '+' : '-')
float sigmoid(float x) {
return 1 / (1 + exp((double) -x));
}
main() {
int d, q, i, a, t;
scanf("%d %d\n", &d, &q);
int beta[d+1];
for (i=0; i<d; i++)
scanf("%d ", &beta[i]);
scanf("%d\n", &beta[i]);
while (q--) {
a = beta[0];
for (i=1; d>i; i++) {
scanf("%d ", &t);
a += beta[i] * t;
}
scanf("%d\n", &t);
a += beta[i] * t;
putchar(classify(sigmoid(a)));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment