#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define db(a) \
cout << #a << " = " << a << endl
#define db2(a, b) \
cout << #a << " = " << a << " " << #b << " = " << b << endl
#define inf (1<<30)
#define foreach(it, m) \
for (typeof(m.begin()) it = m.begin(); it != m.end(); it++)
using namespace std;
int main() {
#ifdef dennisbot
freopen("in.in", "r", stdin);
freopen("ou.out", "w", stdout);
#endif
char s[20];
while (gets(s) != NULL) {
if (s[0] == '_') continue;
int mask = 0;
for (int i = 8; i >= 4; i--) {
if (s[9 - i] == 'o') mask |= 1 << (i - 1);
}
for (int i = 2; i >= 0; i--) {
if (s[9 - i] == 'o') mask |= 1 << i;
}
printf("%c", (char)mask);
}
return 0;
}
here is the statementjueves, 12 de julio de 2012
10878 - Decode the tape, uva
471 - Magic Numbers, uva
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define db(a) \
cout << #a << " = " << a << endl
#define db2(a, b) \
cout << #a << " = " << a << " " << #b << " = " << b << endl
#define inf (1<<30)
#define foreach(it, m) \
for (typeof(m.begin()) it = m.begin(); it != m.end(); it++)
using namespace std;
bool has_repeated_digits(long long int s) {
int mask = 0;
while (s) {
if (mask & (1 << (s % 10)))
return true;
mask |= 1 << (s % 10);
s /= 10;
}
return false;
}
int main() {
#ifdef dennisbot
freopen("in.in", "r", stdin);
freopen("ou.out", "w", stdout);
#endif
int t;
long long int max_s1 = 9876543210, s1, s2, max_s2, N;
scanf("%d", &t);
for (; t--;) {
scanf("%lld", &N);
max_s2 = max_s1 / N;
for (s2 = 1; s2 <= max_s2; s2++) {
if (has_repeated_digits(s2)) continue;
s1 = s2 * N;
if (has_repeated_digits(s1)) continue;
printf("%lld / %lld = %lld\n", s1, s2, N);
}
if (t)
puts("");
}
return 0;
}
here is the statementmiércoles, 20 de junio de 2012
846 - Steps, UVA
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#define db(a) \
cout << #a << " = " << a << endl
#define db2(a, b) \
cout << #a << " = " << a << " " << #b << " = " << b << endl
#define inf (1<<30)
#define foreach(it, m) \
for (typeof(m.begin()) it = m.begin(); it != m.end(); it++)
using namespace std;
int main() {
#ifdef dennisbot
freopen("in.in", "r", stdin);
//freopen("ou.out", "w", stdout);
#endif
int x, y;
int t;
scanf("%d", &t);
//db(t);
for (int i = 0; i < t; i++) {
scanf("%d%d", &x , &y);
//db2(x, y);
if (x == y) {
puts("0");
continue;
}
int n = (int)sqrt(y - x);
//db(n);
if (n * n == y - x)
n = 2 * n - 1;
else
if (n * (n + 1) < y - x) {
n = 2 * n + 1;
}
else n = 2 * n;
/*db2(x, y);
db(n);*/
printf("%d\n", n);
}
return 0;
}
a good explanation can be found hereAlgorithmist
Suscribirse a:
Entradas (Atom)