Skip to content

Instantly share code, notes, and snippets.

@enamcse
Created May 1, 2012 22:30
Show Gist options
  • Save enamcse/2571975 to your computer and use it in GitHub Desktop.
Save enamcse/2571975 to your computer and use it in GitHub Desktop.
UVa 11805 11854 11877 11942 11984 12015 12149 12289
#include <stdio.h>
int main()
{
int t, k, n, p, i, j, ball;
scanf("%d", &t);
for (i = 0; i < t; ++i)
{
scanf("%d %d %d", &n, &k, &p);
if (n >= 2 && k >= 1 && n >= k && p >= 1)
{
ball = k;
for (j = 0; j < p; ++j)
{
++ball;
if (ball == n + 1) ball = 1;
}
printf("Case %d: %d\n", i + 1, ball);
}
}
return 0;
}
#include <stdio.h>
int main()
{
int a, b, c;
double x, y, z;
scanf("%d %d %d", &a, &b, &c);
while(a != 0 && b != 0 && c!= 0)
{
x = a;
y = b;
z = c;
if(((x * x) + (y * y)) == (z * z)) printf("right\n");
else if(((x * x) + (z * z)) == (y * y)) printf("right\n");
else if(((z * z) + (y * y)) == (x * x)) printf("right\n");
else printf("wrong\n");
scanf("%d %d %d", &a, &b, &c);
}
return 0;
}
#include <stdio.h>
int main()
{
int n, count;
scanf("%d", &n);
while ( n != 0)
{
count = n / 2;
printf("%d\n", count);
scanf("%d", &n);
}
return 0;
}
#include <stdio.h>
int main()
{
int i, j, n, a[15], flag;
scanf("%d", &n);
for (i = 0; i < n; ++i)
{
flag = 1;
for (j = 0; j < 10; ++j)
scanf(" %d", &a[j]);
if (a[0] > a[1])
{
for (j = 1; j < 9; ++j)
if (a[j] < a[j + 1]) flag = 0;
}
else if (a[0] < a[1])
{
for (j = 1; j < 9; ++j)
if (a[j] > a[j + 1]) flag = 0;
}
else
for (j = 1; j < 9; ++j)
{
if (a[j] > a[j + 1])
{
for (j = j; j < 9; ++j)
if (a[j] < a[j + 1]) flag = 0;
}
else if (a[j] < a[j + 1])
{
for (j = j; j < 9; ++j)
if (a[j] > a[j + 1]) flag = 0;
}
}
if (i == 0) printf("Lumberjacks:\n");
if (flag == 1) printf("Ordered\n");
else printf("Unordered\n");
}
return 0;
}
#include <stdio.h>
int main()
{
int t, i;
float celc, fern, initial;
scanf("%d", &t);
for (i = 1; i <= t; ++i)
{
scanf("%f %f", &initial, &fern);
celc = fern / 1.8;
celc += initial;
printf("Case %d: %.2f\n", i, celc);
}
return 0;
}
#include <stdio.h>
int main()
{
int n, rank[100][10], i, j, h;
char page[10][100][100];
scanf("%d", &n);
for (i = 0; i < n; ++i)
for (j = 0; j < 10; ++j)
{
scanf("%s", page[i][j]);
scanf("%d", &rank[i][j]);
}
for (i = 0; i < n; ++i)
{
h = 0;
printf("Case #%d:\n", i+1);
for (j = 0; j < 10; ++j)
if (h < rank[i][j]) h = rank[i][j];
for (j = 0; j < 10; ++j)
if (h == rank[i][j]) printf("%s\n", page[i][j]);
}
return 0;
}
#include <stdio.h>
int main()
{
int n;
while(scanf("%d", &n) == 1 && n != 0)
{
n = (n * (n + 1) * (2 * n + 1)) / 6;
printf("%d\n", n);
}
return 0;
}
#include <stdio.h>
#include <string.h>
int main()
{
int n, i;
char numb[5];
scanf("%d", &n);
for (i = 0; i < n; ++i)
{
scanf("%s", numb);
if(strlen(numb) == 5) printf("3\n");
else if(numb[0] == 'o' && (numb[1] == 'n' || numb[2] == 'e')) printf("1\n");
else if(numb[0] == 't' && (numb[1] == 'w' || numb[2] == 'o')) printf("2\n");
else if(numb[0] != 'o' && numb[1] == 'n' && numb[2] == 'e') printf("1\n");
else if(numb[0] != 't' && numb[1] == 'w' && numb[2] == 'o') printf("2\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment