Created
December 10, 2014 05:04
-
-
Save vikhyat/bece755992a5d1b47e5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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