Created
May 1, 2012 22:08
-
-
Save enamcse/2571834 to your computer and use it in GitHub Desktop.
UVa 10432 10696 10783 10812 10921 10931 10970 11150 11172 11185
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
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
double n, r, area; | |
while (scanf("%lf %lf", &r, &n) == 2) | |
{ | |
area = n * r * r * sin(2 * 3.141592653589793238462643383279 / n) / 2; | |
printf("%.3lf\n", area); | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
int f91 (int n); | |
int main() | |
{ | |
int n, num; | |
while(scanf("%d", &n) == 1) | |
{ | |
if(n == 0)break; | |
num = f91(n); | |
printf("f91(%d) = %d\n", n, num); | |
} | |
return 0; | |
} | |
int f91 (int n) | |
{ | |
if (n >= 101) return n - 10; | |
else return 91; | |
} |
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
#include <stdio.h> | |
int main() | |
{ | |
int a, b, i = 0, n, c, d = 0, sum, temp; | |
scanf("%d", &n); | |
while (i < n) | |
{ | |
sum = 0; | |
scanf("%d %d", &a, &b); | |
temp = a; | |
c = a % 2; | |
while (c == 1) | |
{ | |
sum = sum + temp; | |
temp = temp + 2; | |
if ((temp == (b + 1)) || (temp == (b + 2))) c = 2; | |
} | |
if (c == 0) | |
{ | |
d = 1; | |
temp = a + 1; | |
} | |
while (d == 1) | |
{ | |
sum = sum + temp; | |
temp = temp + 2; | |
if ((temp == (b + 1)) || (temp == (b + 2))) d = 2; | |
} | |
printf("Case %d: %d\n", i + 1, sum); | |
i++; | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
int main() | |
{ | |
int n, i, sum, dif, a, b, add; | |
scanf("%d", &n); | |
for (i = 0; i < n; ++i) | |
{ | |
scanf("%d %d", &sum, &dif); | |
add = sum + dif; | |
if (sum >= dif && add % 2 == 0) | |
{ | |
a = add / 2; | |
b = sum - a; | |
printf("%d %d\n", a, b); | |
} | |
else printf("impossible\n"); | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
int main() | |
{ | |
int n, i, sum, dif, a, b, add; | |
scanf("%d", &n); | |
for (i = 0; i < n; ++i) | |
{ | |
scanf("%d %d", &sum, &dif); | |
add = sum + dif; | |
if (sum >= dif && add % 2 == 0) | |
{ | |
a = add / 2; | |
b = sum - a; | |
printf("%d %d\n", a, b); | |
} | |
else printf("impossible\n"); | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
#include <string.h> | |
int main() | |
{ | |
int i, j, k, len; | |
char ch[1000]; | |
while (scanf("%s", ch) == 1) | |
{ | |
len = strlen(ch); | |
for (i = 0; i < len; ++i) | |
switch (ch[i]) | |
{ | |
case 'A': | |
case 'B': | |
case 'C': | |
ch[i] = '2'; | |
break; | |
case 'D': | |
case 'E': | |
case 'F': | |
ch[i] = '3'; | |
break; | |
case 'G': | |
case 'H': | |
case 'I': | |
ch[i] = '4'; | |
break; | |
case 'J': | |
case 'K': | |
case 'L': | |
ch[i] = '5'; | |
break; | |
case 'M': | |
case 'N': | |
case 'O': | |
ch[i] = '6'; | |
break; | |
case 'P': | |
case 'Q': | |
case 'R': | |
case 'S': | |
ch[i] = '7'; | |
break; | |
case 'T': | |
case 'U': | |
case 'V': | |
ch[i] = '8'; | |
break; | |
case 'W': | |
case 'X': | |
case 'Y': | |
case 'Z': | |
ch[i] = '9'; | |
break; | |
default: | |
break; | |
} | |
printf("%s\n", ch); | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
#include <string.h> | |
int main() | |
{ | |
long int num; | |
int count; | |
int i, j, a[100]; | |
scanf("%ld", &num); | |
while(num > 0) | |
{ | |
count = 0; | |
for (i = 0; num != 0; ++i) | |
{ | |
a[i] = num % 2; | |
num = num / 2; | |
if (a[i] == 1) count++; | |
} | |
printf("The parity of "); | |
for (j = i - 1; j >= 0; --j) | |
printf("%d", a[j]); | |
printf(" is %d (mod 2).\n", count); | |
scanf("%ld", &num); | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
int main() | |
{ | |
int m, n, cut; | |
while(scanf("%d %d", &m, &n) == 2) | |
{ | |
cut = m - 1; | |
cut += (n - 1) * m; | |
printf("%d\n", cut); | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
int main() | |
{ | |
int n, count; | |
while (scanf("%d", &n) == 1) | |
{ | |
count = n + n / 2; | |
printf("%d\n", count); | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
int main() | |
{ | |
int a, b, i= 0, n; | |
scanf("%d", &n); | |
while (i < n) | |
{ | |
scanf("%d %d", &a, &b); | |
if (a > b) printf(">\n"); | |
else if (a < b) printf("<\n"); | |
else printf("=\n"); | |
i++; | |
} | |
return 0; | |
} |
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
#include <stdio.h> | |
#include <string.h> | |
int main() | |
{ | |
long int num; | |
int i, j, a[100]; | |
scanf("%ld", &num); | |
while(num >= 0) | |
{ | |
if (num == 0) | |
{ | |
i = 1; | |
a[0] = 0; | |
} | |
else | |
for (i = 0; num != 0; ++i) | |
{ | |
a[i] = num % 3; | |
num = num / 3; | |
} | |
for (j = i - 1; j >= 0; --j) | |
printf("%d", a[j]); | |
printf("\n"); | |
scanf("%ld", &num); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment