Last active
August 29, 2015 13:57
-
-
Save longbuilder/9580761 to your computer and use it in GitHub Desktop.
FOJ Accepted Source
This file contains hidden or 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
| #include <stdio.h> | |
| #include <math.h> | |
| int main() | |
| { | |
| double x,y,a,b; | |
| double m,n; | |
| freopen("data.txt", "r", stdin); | |
| while(scanf("%lf %lf %lf %lf", &a, &b, &x, &y) !=EOF) | |
| { | |
| if(a==0 && b==0 && x==0 && y==0) | |
| return 1; | |
| if(a<b) | |
| { | |
| double t = a; | |
| a = b; | |
| b = t; | |
| } | |
| if(x<y) | |
| { | |
| double t = x; | |
| x = y; | |
| y = t; | |
| } | |
| if(a>x && b>y) | |
| { | |
| printf("Escape is possible.\n"); | |
| continue; | |
| } | |
| else if(x*x+y*y>a*a+b*b) | |
| { | |
| printf("Box cannot be dropped.\n"); | |
| continue; | |
| } | |
| else | |
| { | |
| m = (a - sqrt((double)(x*x+y*y-b*b)))/2; | |
| n = (b - sqrt((double)(x*x+y*y-a*a)))/2; | |
| if(m*m+n*n>y*y) | |
| printf("Escape is possible.\n"); | |
| else | |
| printf("Box cannot be dropped.\n"); | |
| } | |
| } | |
| return 0; | |
| fclose(stdin); | |
| } |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <string.h> | |
| int main() | |
| { | |
| long a, b; | |
| char str[30]; | |
| freopen("data.txt", "r", stdin); | |
| while(scanf("%ld %ld", &a, &b) != EOF) | |
| { | |
| memset(str, 0, 30); | |
| long res = a-b; | |
| sprintf(str, "%ld", res); | |
| int len = strlen(str); | |
| int q = len%3; | |
| for(int i=0; i<len; i++) | |
| { | |
| printf("%c", str[i]); | |
| int n; | |
| n = i+1; | |
| int start; | |
| if(res >= 0) | |
| start = 1; | |
| else | |
| start = 2; | |
| if(n%3 == q && n<len-2 && n >= start) | |
| { | |
| printf(","); | |
| } | |
| } | |
| printf("\n"); | |
| } | |
| fclose(stdin); | |
| } |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <string.h> | |
| bool compare(char *s1, char *s2) | |
| { | |
| int n = strlen(s1); | |
| if(n != strlen(s2)) | |
| { | |
| return false; | |
| } | |
| else | |
| { | |
| for(int i=0; i<n; i++) | |
| { | |
| char c1 = s1[i]; | |
| char c2 = s2[i]; | |
| if(c1>='A' && c1<='Z') | |
| { | |
| c1 += 32; | |
| } | |
| if(c2>='A' && c2<='Z') | |
| { | |
| c2 += 32; | |
| } | |
| if(c1 != c2) | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| int main() | |
| { | |
| char word[1000][20]; | |
| int n; | |
| int flag[1000]; | |
| for(int i=0; i<1000; i++) | |
| { | |
| memset(word[i], 0 ,20); | |
| } | |
| freopen("data.txt", "r", stdin); | |
| while(scanf("%d", &n) != EOF) | |
| { | |
| getchar(); | |
| for(int i=0; i<n; i++) | |
| { | |
| gets(word[i]); | |
| } | |
| for(int i=0; i<n; i++) | |
| { | |
| flag[i] = 1; | |
| } | |
| for(int i=0; i<n; i++) | |
| for(int j=i+1; j<n; j++) | |
| { | |
| if(!flag[j] || !flag[i]) | |
| continue; | |
| if(compare(word[i], word[j])) | |
| { | |
| flag[j] = 0; | |
| } | |
| } | |
| int sum = 0; | |
| for(int i=0; i<n; i++) | |
| { | |
| if(flag[i]) | |
| sum++; | |
| } | |
| printf("%d\n", sum); | |
| for(int i=0; i<n; i++) | |
| { | |
| memset(word[i], 0 ,20); | |
| } | |
| } | |
| fclose(stdin); | |
| } |
This file contains hidden or 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
| #include <stdio.h> | |
| #include <math.h> | |
| int func(int m, int i) | |
| { | |
| if(i == 0) | |
| return 1; | |
| else if(i == 1) | |
| return m; | |
| else if(i > m/2) | |
| { | |
| return func(m, m-i); | |
| } | |
| else | |
| { | |
| int sum1 = 1; | |
| int sum2 = 1; | |
| for(int j = 0; j<i; j++) | |
| { | |
| sum1 *= m-j; | |
| sum2 *= i-j; | |
| } | |
| return sum1/sum2; | |
| } | |
| } | |
| int main() | |
| { | |
| int m,n; | |
| freopen("data.txt", "r", stdin); | |
| while(scanf("%d %d", &n, &m) !=EOF) | |
| { | |
| int sum = 0; | |
| for(int i=0; i<m; i++) | |
| { | |
| int tmp1 = func(m, i); | |
| int tmp2 = 1; | |
| for(int j=0; j<n; j++) | |
| { | |
| tmp2 *= m-i; | |
| } | |
| if(i%2 == 0) | |
| { | |
| sum +=(tmp1*tmp2); | |
| } | |
| else | |
| { | |
| sum -=(tmp1*tmp2); | |
| } | |
| } | |
| printf("%d\n", sum); | |
| } | |
| fclose(stdin); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment