#include<stdio.h>
int a[10] = {
2, 7, 2, 3, 3, 4, 2, 5, 1, 2
};
int main()
{
int x;
while(~scanf("%d", &x))
{
printf("%d\n", a[x%10] * a[x/10]);
}
return 0;
}
B - Modular Equations
#include<stdio.h>
#include<string.h>
int main()
{
int a, b, ans, k, i;
while(~scanf("%d%d", &a, &k))
{
if( a < k )
{
printf("0\n");
continue;
}
else if( a == k )
{
printf("infinity\n");
continue;
}
ans = 0;
for( i = 1; i * i < a - k; i ++ )
if( ( a - k ) % i == 0 )
{
if( i > k )
ans++;
if( (a-k) / i > k )
ans++;
}
if( i * i == (a-k) && i > k )
ans++;
printf("%d\n", ans);
}
return 0;
}
C - Treasure
#include <stdio.h>
#include <string.h>
int main()
{
char s[100002];
scanf("%s", s);
int len = strlen(s);
int pl[100002];
int i, cnt = 0, last;
for (i = 0; i < len; i++)
{
if (s[i] == '(')
pl[i] = 1, cnt++;
else if (s[i] == ')')
pl[i] = -1, cnt--;
else
pl[i] = -1, cnt--, last = i;
}
pl[last] = -cnt-1;
bool ok = ((-cnt-1) < 0);
int tot = 0;
for (i = 0; i < len; i++)
{
tot += pl[i];
if (tot < 0)
ok = false;
}
if (!ok)
printf("-1\n");
else
{
for (i = 0; i < len; i++)
{
if (s[i] == '#')
printf("%d\n", -pl[i]);
}
}
return 0;
}