buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
#include <bitset>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif
#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it = (c).begin(); it != (c).end(); ++it)
#define RITER(c) __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it = (c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n) REPEAT(i, 0, n)
#define RREP(i, n) RREPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (k + n); ++i)
#define RREPEAT(i, k, n) for (int i = (k) + (n)-1; i >= (k); --i)
#define FROMTO(i, f, t) for (int i = f; i < t; i++)
#define ALL(c) (c).begin(), (c).end()
#define LLPOW(p1, p2) ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A) (sizeof(A) / sizeof((A)[0]))
#define CIN_NO_SYNC \
do { \
cin.tie(0); \
ios_base::sync_with_stdio(false); \
} while (0)
#define GETSTR(p) fgets((p), sizeof(p), stdin)
#define CHOMP(p) \
do { \
char *_q = (p) + strlen(p) - 1; \
if (*_q == '\n' || *_q == '\r') \
*_q = 0; \
} while (0)
#define FILL(m, v) memset(m, v, sizeof(m))
#define mp make_pair
#define pb push_back
template <class _T> _T MAX(_T p1, _T p2) { return (p1 > p2) ? p1 : p2; }
template <class _T> _T MIN(_T p1, _T p2) { return (p1 < p2) ? p1 : p2; }
template <class _Tv> inline string join(_Tv &v, string sep = " ") {
ostringstream s;
FOREACH(it, v) {
if (it != v.begin())
s << sep;
s << *it;
};
return s.str();
}
typedef long long ll;
typedef unsigned long long ull;
#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)
#ifdef _DEBUG
template <class _Tv>
inline void _prfe(const char *_n, _Tv _c, bool _p = false) {
ITER(_c) _it = _c.begin();
if (_p) {
cout << _n << " = [" << endl;
for (; _it != _c.end(); ++_it)
cout << " " << *_it << endl;
cout << "]" << endl;
} else {
cout << _n << " = [ " << *_it++;
for (; _it != _c.end(); ++_it)
cout << ", " << *_it;
cout << " ]" << endl;
}
}
#define pf printf
#define pr(n) \
do { \
cout << #n " = " << (n) << endl; \
} while (0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) \
do { \
if (n) \
throw; \
} while (0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif
void solve(vector<vector<int>> &v) {
vector<vector<int>> f;
f.resize(9, vector<int>(9));
map<int, int> mx, my, mb;
REP(i, 9) {
mx.clear();
my.clear();
mb.clear();
REP(j, 9) {
mx[v[i][j]]++;
my[v[j][i]]++;
}
REP(j, 9) {
if (mx[v[i][j]] > 1)
f[i][j] = true;
if (my[v[j][i]] > 1)
f[j][i] = true;
}
int by = i / 3 * 3, bx = i % 3 * 3;
REP(k, 3) REP(l, 3) { mb[v[by + k][bx + l]]++; }
REP(k, 3) REP(l, 3) {
if (mb[v[by + k][bx + l]] > 1)
f[by + k][bx + l] = true;
}
}
REP(i, 9) {
REP(j, 9) { printf("%c%d ", f[i][j] ? '*' : ' ', v[i][j]); }
printf("\n");
}
}
int main() {
int n;
cin >> n;
bool f = false;
REP(i, n) {
vector<vector<int>> v;
v.resize(9);
REP(y, 9) {
v[y].resize(9);
REP(x, 9) { cin >> v[y][x]; }
}
if (f)
cout << endl;
solve(v);
f = true;
}
return 0;
}
|
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
#include <bitset>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif
#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it = (c).begin(); it != (c).end(); ++it)
#define RITER(c) __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it = (c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n) REPEAT(i, 0, n)
#define RREP(i, n) RREPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (k + n); ++i)
#define RREPEAT(i, k, n) for (int i = (k) + (n)-1; i >= (k); --i)
#define FROMTO(i, f, t) for (int i = f; i < t; i++)
#define ALL(c) (c).begin(), (c).end()
#define LLPOW(p1, p2) ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A) (sizeof(A) / sizeof((A)[0]))
#define CIN_NO_SYNC \
do { \
cin.tie(0); \
ios_base::sync_with_stdio(false); \
} while (0)
#define GETSTR(p) fgets((p), sizeof(p), stdin)
#define CHOMP(p) \
do { \
char *_q = (p) + strlen(p) - 1; \
if (*_q == '\n' || *_q == '\r') \
*_q = 0; \
} while (0)
#define FILL(m, v) memset(m, v, sizeof(m))
#define mp make_pair
#define pb push_back
template <class _T> _T MAX(_T p1, _T p2) { return (p1 > p2) ? p1 : p2; }
template <class _T> _T MIN(_T p1, _T p2) { return (p1 < p2) ? p1 : p2; }
template <class _Tv> inline string join(_Tv &v, string sep = " ") {
ostringstream s;
FOREACH(it, v) {
if (it != v.begin())
s << sep;
s << *it;
};
return s.str();
}
typedef long long ll;
typedef unsigned long long ull;
#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)
#ifdef _DEBUG
template <class _Tv>
inline void _prfe(const char *_n, _Tv _c, bool _p = false) {
ITER(_c) _it = _c.begin();
if (_p) {
cout << _n << " = [" << endl;
for (; _it != _c.end(); ++_it)
cout << " " << *_it << endl;
cout << "]" << endl;
} else {
cout << _n << " = [ " << *_it++;
for (; _it != _c.end(); ++_it)
cout << ", " << *_it;
cout << " ]" << endl;
}
}
#define pf printf
#define pr(n) \
do { \
cout << #n " = " << (n) << endl; \
} while (0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) \
do { \
if (n) \
throw; \
} while (0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif
void solve(vector<vector<int>> &v) {
vector<vector<int>> f;
f.resize(9, vector<int>(9));
map<int, int> mx, my, mb;
REP(i, 9) {
mx.clear();
my.clear();
mb.clear();
REP(j, 9) {
mx[v[i][j]]++;
my[v[j][i]]++;
}
REP(j, 9) {
if (mx[v[i][j]] > 1)
f[i][j] = true;
if (my[v[j][i]] > 1)
f[j][i] = true;
}
int by = i / 3 * 3, bx = i % 3 * 3;
REP(k, 3) REP(l, 3) { mb[v[by + k][bx + l]]++; }
REP(k, 3) REP(l, 3) {
if (mb[v[by + k][bx + l]] > 1)
f[by + k][bx + l] = true;
}
}
REP(i, 9) {
REP(j, 9) { printf("%c%d", f[i][j] ? '*' : ' ', v[i][j]); }
printf("\n");
}
}
int main() {
int n;
cin >> n;
bool f = false;
REP(i, n) {
vector<vector<int>> v;
v.resize(9);
REP(y, 9) {
v[y].resize(9);
REP(x, 9) { cin >> v[y][x]; }
}
if (f)
cout << endl;
solve(v);
f = true;
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 944
| 2
|
def get_all_index(a, value)
index = []
_a = a.dup
while _a.include?(value)
next_i = _a.index(value)
index << next_i
_a[next_i] = nil
end
index
end
n = gets.to_i
virgin = true
n.times do
puzzle = [] # Taro's answer
errata = [] # errata for Taro
puts "" unless virgin
9.times do
puzzle << gets.split.map(&:to_i)
errata << Array.new(9, true)
end
# checking row and column
0.upto(8) do |i|
0.upto(8) do |j|
(j+1).upto(8) do |k|
if puzzle[i][j] == puzzle[i][k]
errata[i][j] = false
errata[i][k] = false
end
if puzzle[j][i] == puzzle[k][i]
errata[j][i] = false
errata[k][i] = false
end
end
end
end
# checking box
-1.upto(1) do |i|
-1.upto(1) do |j|
box_index << [i, j]
end
end
[1,4,7].each do |i|
[1,4,7].each do |j|
cb = []
cb_index = []
box_index.each do |b|
cb_index << [b[0] + i, b[1] + j]
cb << puzzle[b[0] + i][b[1] + j]
end
if (temp = cb.uniq.select{ |x| cb.index(x) != cb.rindex(x) }).any?
temp.each do |m|
get_all_index(cb, m).each do |i|
x, y = cb_index[i]
errata[x][y] = false
end
end
end
end
end
# output
0.upto(8) do |i|
0.upto(8) do |j|
if errata[i][j]
print " #{puzzle[i][j]}"
else
print "*#{puzzle[i][j]}"
end
puts "" if j == 8
end
end
virgin = false if virgin
end
|
def get_all_index(a, value)
index = []
_a = a.dup
while _a.include?(value)
next_i = _a.index(value)
index << next_i
_a[next_i] = nil
end
index
end
n = gets.to_i
virgin = true
n.times do
puzzle = []
errata = []
puts "" unless virgin
9.times do
puzzle << gets.split.map(&:to_i)
errata << Array.new(9, true)
end
# checking row and column
0.upto(8) do |i|
0.upto(8) do |j|
(j+1).upto(8) do |k|
if puzzle[i][j] == puzzle[i][k]
errata[i][j] = false
errata[i][k] = false
end
if puzzle[j][i] == puzzle[k][i]
errata[j][i] = false
errata[k][i] = false
end
end
end
end
# checking box
box_index = []
-1.upto(1) do |i|
-1.upto(1) do |j|
box_index << [i, j]
end
end
[1,4,7].each do |i|
[1,4,7].each do |j|
cb = []
cb_index = []
box_index.each do |b|
cb_index << [b[0] + i, b[1] + j]
cb << puzzle[b[0] + i][b[1] + j]
end
if (temp = cb.uniq.select{ |x| cb.index(x) != cb.rindex(x) }).any?
temp.each do |m|
get_all_index(cb, m).each do |i|
x, y = cb_index[i]
errata[x][y] = false
end
end
end
end
end
# output
0.upto(8) do |i|
0.upto(8) do |j|
if errata[i][j]
print " #{puzzle[i][j]}"
else
print "*#{puzzle[i][j]}"
end
puts "" if j == 8
end
end
virgin = false if virgin
end
|
[["+", 0, 652, 196, 737, 8, 736, 0, 662, 31, 22], ["+", 0, 652, 196, 737, 8, 736, 0, 662, 0, 32], ["+", 196, 737, 8, 736, 0, 662, 12, 516, 0, 70], ["+", 196, 737, 8, 736, 0, 662, 12, 516, 0, 73]]
| 4
| 457
| 4
|
R=[0,3,6]
N=list(range(9))
Z=[0]*9
n=eval(input())
while n:
M=[]
F=[[" " for _ in Z] for _ in Z]
M=[list(map(int,input().split())) for _ in Z]
M1=[[M[y][x] for y in N] for x in N]
M2=[[M[y][x:x+3]+M[y+1][x:x+3]+M[y+2][x:x+3]] for x in R for y in R]
for y in N:
A=M[y]
for x in N:
A1=M2[x/3+y/3*3]
a=A[x]
if A.count(a)>1 or M1[x].count(a)>1 or A1.count(a)>1: F[y][x]="*"
for i in N:
s=list(zip(F[i],list(map(str,M[i]))))
print("".join([a+b for a,b in s]))
if n>1: print()
n-=1
|
R=[0,3,6]
N=list(range(9))
Z=[0]*9
n=eval(input())
while n:
M=[]
F=[[" " for _ in Z] for _ in Z]
M=[list(map(int,input().split())) for _ in Z]
M1=[[M[y][x] for y in N] for x in N]
M2=[M[y][x:x+3]+M[y+1][x:x+3]+M[y+2][x:x+3] for y in R for x in R]
for y in N:
A=M[y]
for x in N:
A1=M2[x/3+y/3*3]
a=A[x]
if A.count(a)>1 or M1[x].count(a)>1 or A1.count(a)>1: F[y][x]="*"
for i in N:
s=list(zip(F[i],list(map(str,M[i]))))
print("".join([a+b for a,b in s]))
if n>1: print()
n-=1
|
[["-", 0, 1, 0, 662, 12, 658, 8, 634, 0, 70], ["-", 0, 1, 0, 662, 12, 658, 8, 634, 0, 73], ["-", 0, 1, 0, 662, 12, 658, 0, 659, 31, 22], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 31, 22]]
| 5
| 293
| 6
|
import java.util.Scanner;
public class Main {
public static void main(String arg[]) {
Scanner in = new Scanner(System.in);
String str[][] = {
{},
{"", "a", "b", "c", "d", "e"},
{"", "f", "g", "h", "i", "j"},
{"", "k", "l", "m", "n", "o"},
{"", "p", "q", "r", "s", "t"},
{"", "u", "v", "w", "x", "y"},
{"", "z", ".", "?", "!", " "},
};
while (in.hasNext()) {
int ju = 0;
String s = in.next();
for (int i = 0; i < s.length() - 1; i++) {
if (s.charAt(i) - '0' > 6 || s.charAt(i) - '0' < 0) {
ju = 1;
break;
}
i++;
if (s.charAt(i) - '0' > 5 || s.charAt(i) - '0' < 0) {
ju = 1;
break;
}
}
String ans = "";
if (s.length() % 2 != 0 || ju == 1)
System.out.println("NA");
else {
for (int i = 0; i < s.length() - 1; i += 2) {
ans += (str[s.charAt(i) - '0'][s.charAt(i + 1) - '0']);
}
System.out.println(ans);
}
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String arg[]) {
Scanner in = new Scanner(System.in);
String str[][] = {
{},
{"", "a", "b", "c", "d", "e"},
{"", "f", "g", "h", "i", "j"},
{"", "k", "l", "m", "n", "o"},
{"", "p", "q", "r", "s", "t"},
{"", "u", "v", "w", "x", "y"},
{"", "z", ".", "?", "!", " "},
};
while (in.hasNext()) {
int ju = 0;
String s = in.next();
for (int i = 0; i < s.length() - 1; i++) {
if (s.charAt(i) - '0' > 6 || s.charAt(i) - '0' <= 0) {
ju = 1;
break;
}
i++;
if (s.charAt(i) - '0' > 5 || s.charAt(i) - '0' <= 0) {
ju = 1;
break;
}
}
String ans = "";
if (s.length() % 2 != 0 || ju == 1)
System.out.println("NA");
else {
for (int i = 0; i < s.length() - 1; i += 2) {
ans += (str[s.charAt(i) - '0'][s.charAt(i + 1) - '0']);
}
System.out.println(ans);
}
}
}
}
|
[["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 19]]
| 3
| 407
| 4
|
#include <stdio.h>
#include <string.h>
char table[6][7] = {
{'0', '0', '0', '0', '0', '0', '0'}, {'0', 'a', 'f', 'k', 'p', 'u', 'z'},
{'0', 'b', 'g', 'l', 'q', 'v', '.'}, {'0', 'c', 'g', 'm', 'r', 'w', '?'},
{'0', 'd', 'i', 'n', 's', 'x', '!'}, {'0', 'e', 'j', 'o', 't', 'y', ' '},
};
int main() {
char str[200] = {};
int length = 0, i;
char message[201];
while (fgets(str, sizeof(str), stdin)) {
if ((length = strlen(str) - 1) % 2) {
printf("NA\n");
continue;
}
i = 0;
memset((void *)message, 0, strlen(message));
while (i < length) {
// printf( "%c %c %c\n", str[i], str[i+1], table[str[i+1]-'0'][str[i]-'0']
// );
if (str[i] - '0' > 0 && str[i] - '0' < 7 && str[i + 1] - '0' > 0 &&
str[i + 1] - '0' < 6) {
message[i / 2] = table[str[i + 1] - '0'][str[i] - '0'];
i += 2;
} else {
printf("NA\n");
i = -1;
break;
}
}
if (i == -1) {
continue;
} else {
i++;
message[i / 2] = 0;
printf("%s\n", message);
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
char table[6][7] = {
{'0', '0', '0', '0', '0', '0', '0'}, {'0', 'a', 'f', 'k', 'p', 'u', 'z'},
{'0', 'b', 'g', 'l', 'q', 'v', '.'}, {'0', 'c', 'h', 'm', 'r', 'w', '?'},
{'0', 'd', 'i', 'n', 's', 'x', '!'}, {'0', 'e', 'j', 'o', 't', 'y', ' '},
};
int main() {
char str[300] = {};
int length = 0, i;
char message[201];
while (fgets(str, sizeof(str), stdin)) {
if ((length = strlen(str) - 1) % 2) {
printf("NA\n");
continue;
}
i = 0;
memset((void *)message, 0, strlen(message));
while (i < length) {
// printf( "%c %c %c\n", str[i], str[i+1], table[str[i+1]-'0'][str[i]-'0']
// );
if (str[i] - '0' > 0 && str[i] - '0' < 7 && str[i + 1] - '0' > 0 &&
str[i + 1] - '0' < 6) {
message[i / 2] = table[str[i + 1] - '0'][str[i] - '0'];
i += 2;
} else {
printf("NA\n");
i = -1;
break;
}
}
if (i == -1) {
continue;
} else {
i++;
message[i / 2] = 0;
printf("%s\n", message);
}
}
return 0;
}
|
[["-", 49, 50, 51, 83, 0, 83, 0, 103, 0, 125], ["+", 49, 50, 51, 83, 0, 83, 0, 103, 0, 125], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
| 0
| 439
| 4
|
#include <stdio.h>
int main() {
char s[203];
char c[6][6] = {{"abcde"}, {"fghij"}, {"klmno"},
{"pqrst"}, {"uvwxy"}, {"z.?! "}};
int i;
while (fgets(s, 202, stdin) != NULL) {
char b[102] = {0};
for (i = 0; s[i] != 10; i += 2) {
if (0 <= s[i] - '0' && s[i] - '0' <= 6 && 0 <= s[i + 1] - '0' &&
s[i + 1] - '0' <= 5) {
b[i / 2] = c[s[i] - '0' - 1][s[i + 1] - '0' - 1];
} else {
printf("NA\n");
break;
}
}
if (s[i] == 10) {
b[i / 2] = 0;
printf("%s\n", b);
}
}
return 0;
}
|
#include <stdio.h>
int main() {
char s[203];
char c[6][6] = {{"abcde"}, {"fghij"}, {"klmno"},
{"pqrst"}, {"uvwxy"}, {"z.?! "}};
int i;
while (fgets(s, 202, stdin) != NULL) {
char b[102] = {0};
for (i = 0; s[i] != 10; i += 2) {
if (1 <= s[i] - '0' && s[i] - '0' <= 6 && 1 <= s[i + 1] - '0' &&
s[i + 1] - '0' <= 5) {
b[i / 2] = c[s[i] - '0' - 1][s[i + 1] - '0' - 1];
} else {
printf("NA\n");
break;
}
}
if (s[i] == 10) {
b[i / 2] = 0;
printf("%s\n", b);
}
}
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 13], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 31, 13], ["-", 15, 23, 0, 16, 31, 16, 12, 16, 31, 13], ["+", 15, 23, 0, 16, 31, 16, 12, 16, 31, 13]]
| 0
| 241
| 4
|
#include <stdio.h>
#include <string.h>
const char *table[] = {
"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! ",
};
int main(void) {
char msg[256];
while (~scanf("%s", msg)) {
int i;
char decode[256] = {0};
int len = strlen(msg);
if (len % 2) {
puts("NA");
continue;
}
for (i = 0; i < len / 2; i++) {
int a = msg[i * 2] - '0';
int b = msg[i * 2 + 1] - '0';
if (a < 1 || a > 6 || b < 1 || b > 5) {
puts("NA");
i = len + 1;
}
decode[i] = table[a - 1][b - 1];
}
if (i < len) {
puts(decode);
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
const char *table[] = {
"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! ",
};
int main(void) {
char msg[256];
while (~scanf("%s", msg)) {
int i;
char decode[256] = {0};
int len = strlen(msg);
if (len % 2) {
puts("NA");
continue;
}
for (i = 0; i < len / 2; i++) {
int a = msg[i * 2] - '0';
int b = msg[i * 2 + 1] - '0';
if (a < 1 || a > 6 || b < 1 || b > 5) {
puts("NA");
i = len + 1;
break;
}
decode[i] = table[a - 1][b - 1];
}
if (i < len) {
puts(decode);
}
}
return 0;
}
|
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
| 0
| 216
| 2
|
#include <stdio.h>
#define A 0
#define B 1
int main(void) {
int i, a, b;
int mode;
char str[210];
char ans[105];
while (scanf("%s", str) != EOF) {
mode = A;
for (i = 0; str[i] != 0; i++) {
if (str[i] < '1' || '6' < str[i]) {
mode = B;
break;
}
if (mode == A) {
a = str[i] - '0';
mode = B;
} else {
if (str[i] == 6) {
break;
}
b = str[i] - '0';
switch (a) {
case 1:
ans[i / 2] = 'a' + b - 1;
break;
case 2:
ans[i / 2] = 'f' + b - 1;
break;
case 3:
ans[i / 2] = 'k' + b - 1;
break;
case 4:
ans[i / 2] = 'p' + b - 1;
break;
case 5:
ans[i / 2] = 'u' + b - 1;
break;
case 6:
ans[i / 2] = b == 1 ? 'z'
: b == 2 ? '.'
: b == 3 ? '?'
: b == 4 ? '!'
: ' ';
break;
}
mode = A;
}
}
ans[i / 2] = 0;
if (mode == B) {
puts("NA");
continue;
} else {
puts(ans);
}
}
return 0;
}
|
#include <stdio.h>
#define A 0
#define B 1
int main(void) {
int i, a, b;
int mode;
char str[210];
char ans[105];
while (scanf("%s", str) != EOF) {
mode = A;
for (i = 0; str[i] != 0; i++) {
if (str[i] < '1' || '6' < str[i]) {
mode = B;
break;
}
if (mode == A) {
a = str[i] - '0';
mode = B;
} else {
if (str[i] == '6') {
break;
}
b = str[i] - '0';
switch (a) {
case 1:
ans[i / 2] = 'a' + b - 1;
break;
case 2:
ans[i / 2] = 'f' + b - 1;
break;
case 3:
ans[i / 2] = 'k' + b - 1;
break;
case 4:
ans[i / 2] = 'p' + b - 1;
break;
case 5:
ans[i / 2] = 'u' + b - 1;
break;
case 6:
ans[i / 2] = b == 1 ? 'z'
: b == 2 ? '.'
: b == 3 ? '?'
: b == 4 ? '!'
: ' ';
break;
}
mode = A;
}
}
ans[i / 2] = 0;
if (mode == B) {
puts("NA");
} else {
puts(ans);
}
}
return 0;
}
|
[["+", 0, 57, 15, 23, 0, 16, 12, 103, 0, 104], ["-", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
| 0
| 347
| 4
|
/*
AizuOnline A0127
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
// Global data section
char msg[401];
char cvtmsg[201];
//
conv(char n1, char n2) {
int r;
if (n1 < '0' || n1 > '6' || n2 < '0' || n2 > '5')
return (-1);
r = ((n1 - '0') - 1) * 5 + (n2 - '0' - 1);
if (r < 26)
return ('a' + r);
else
return (".?! "[(n2 - '2')]);
}
main() {
int i, j, l;
char cvt;
while (EOF != scanf("%s ", msg)) {
memset(cvtmsg, 0, sizeof(cvtmsg));
l = strlen(msg);
if ((l % 2) == 1)
goto NA;
for (i = 0, j = 0; i < l; i += 2) {
cvt = conv(msg[i], msg[i + 1]);
if (cvt == -1)
goto NA;
cvtmsg[j++] = cvt;
}
cvtmsg[j] = 0;
printf("%s\n", cvtmsg);
continue;
NA:
printf("NA\n");
}
return (0);
}
|
/*
AizuOnline A0127
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
// Global data section
char msg[401];
char cvtmsg[201];
//
conv(char n1, char n2) {
int r;
if (n1 < '1' || n1 > '6' || n2 < '1' || n2 > '5')
return (-1);
r = ((n1 - '0') - 1) * 5 + (n2 - '0' - 1);
if (r < 26)
return ('a' + r);
else
return (".?! "[(n2 - '2')]);
}
main() {
int i, j, l;
char cvt;
while (EOF != scanf("%s ", msg)) {
memset(cvtmsg, 0, sizeof(cvtmsg));
l = strlen(msg);
if ((l % 2) == 1)
goto NA;
for (i = 0, j = 0; i < l; i += 2) {
cvt = conv(msg[i], msg[i + 1]);
if (cvt == -1)
goto NA;
cvtmsg[j++] = cvt;
}
cvtmsg[j] = 0;
printf("%s\n", cvtmsg);
continue;
NA:
printf("NA\n");
}
return (0);
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 31, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["-", 0, 16, 31, 16, 12, 16, 12, 103, 0, 125], ["+", 0, 16, 31, 16, 12, 16, 12, 103, 0, 125]]
| 0
| 278
| 4
|
#include <stdio.h>
#include <string.h>
int main() {
char str[250], ans[250],
tmp[10][10] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
int i, flg, l, a, cnt;
while (scanf("%s", str) != EOF) {
for (i = 0; i < 240; i++)
ans[i] = 0;
l = strlen(str);
if (l % 2 == 1) {
exit:
printf("NA\n");
} else {
for (cnt = 0, i = 0; i < l; i += 2, cnt++) {
if (!(str[i] >= '1' && str[i] <= '6' && str[i + 1] >= '1' &&
str[i + 1] <= '6'))
goto exit;
ans[cnt] = tmp[(str[i] - '0' - 1)][(str[i + 1] - '0' - 1)];
}
str[cnt] = '\0';
printf("%s\n", ans);
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main() {
char str[250], ans[250],
tmp[10][10] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
int i, flg, l, a, cnt;
while (scanf("%s", str) != EOF) {
for (i = 0; i < 240; i++)
ans[i] = 0;
l = strlen(str);
if (l % 2 == 1) {
exit:
printf("NA\n");
} else {
for (cnt = 0, i = 0; i < l; i += 2, cnt++) {
if (!(str[i] >= '1' && str[i] <= '6' && str[i + 1] >= '1' &&
str[i + 1] <= '5'))
goto exit;
ans[cnt] = tmp[(str[i] - '0' - 1)][(str[i + 1] - '0' - 1)];
}
str[cnt] = '\0';
printf("%s\n", ans);
}
}
return 0;
}
|
[["-", 28, 23, 0, 16, 12, 16, 12, 103, 0, 125], ["+", 28, 23, 0, 16, 12, 16, 12, 103, 0, 125]]
| 0
| 261
| 2
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i;
char code[300], mes[150];
char encode[6][5] = {{'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
{'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
{'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '}};
int main() {
while (fgets(code, 300, stdin) != NULL) {
code[strlen(code) - 1] = '\0';
if (strlen(code) % 2 != 0)
printf("NA\n");
else {
for (i = 0; i < (signed)strlen(code); i += 2) {
if (code[i] - '1' < 0 || code[i] - '1' > 6 || code[i + 1] - '1' < 0 ||
code[i + 1] - '1' > 5) {
i = 999;
printf("NA\n");
} else
mes[i / 2] = encode[code[i] - '1'][code[i + 1] - '1'];
}
if (i < 999) {
mes[i / 2] = '\0';
printf("%s\n", mes);
}
}
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i;
char code[300], mes[150];
char encode[6][5] = {{'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
{'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
{'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '}};
int main() {
while (fgets(code, 300, stdin) != NULL) {
code[strlen(code) - 1] = '\0';
if (strlen(code) % 2 != 0)
printf("NA\n");
else {
for (i = 0; i < (signed)strlen(code); i += 2) {
if (code[i] - '1' < 0 || code[i] - '1' > 5 || code[i + 1] - '1' < 0 ||
code[i + 1] - '1' > 4) {
i = 999;
printf("NA\n");
} else
mes[i / 2] = encode[code[i] - '1'][code[i + 1] - '1'];
}
if (i < 999) {
mes[i / 2] = '\0';
printf("%s\n", mes);
}
}
}
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 13], ["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
| 0
| 370
| 4
|
#include <iostream>
using namespace std;
int main() {
string msg;
while (cin >> msg) {
if (msg.length() % 2) {
cout << "NA" << endl;
continue;
}
string res = "";
bool OK = true;
for (int i = 0; i < msg.length(); i += 2) {
int x = msg[i] - '0', y = msg[i + 1] - '0';
if (x < 1 || x > 6 || y < 1 || y > 6) {
OK = false;
break;
}
char z = (x - 1) * 5 + (y - 1) + 'a';
if ('a' <= z && z <= 'z')
res.append(1, z);
else {
if (z - 'a' == 26)
res.append(1, '.');
if (z - 'a' == 27)
res.append(1, '?');
if (z - 'a' == 28)
res.append(1, '!');
if (z - 'a' == 29)
res.append(1, ' ');
}
}
if (OK) {
cout << res << endl;
} else {
cout << "NA" << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
string msg;
while (cin >> msg) {
if (msg.length() % 2) {
cout << "NA" << endl;
continue;
}
string res = "";
bool OK = true;
for (int i = 0; i < msg.length(); i += 2) {
int x = msg[i] - '0', y = msg[i + 1] - '0';
if (x < 1 || x > 6 || y < 1 || y > 5) {
OK = false;
break;
}
char z = (x - 1) * 5 + (y - 1) + 'a';
if ('a' <= z && z <= 'z')
res.append(1, z);
else {
if (z - 'a' == 26)
res.append(1, '.');
if (z - 'a' == 27)
res.append(1, '?');
if (z - 'a' == 28)
res.append(1, '!');
if (z - 'a' == 29)
res.append(1, ' ');
}
}
if (OK) {
cout << res << endl;
} else {
cout << "NA" << endl;
}
}
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 285
| 2
|
#include <bits/stdc++.h>
using namespace std;
char table[5][6] = {{'a', 'f', 'k', 'p', 'u', 'z'},
{'b', 'g', 'l', 'q', 'v', '.'},
{'c', 'h', 'm', 'r', 'w', '?'},
{'d', 'i', 'n', 's', 'x', '!'},
{'e', 'j', 'o', 't', 'y', ' '}};
main() {
string s;
while (cin >> s) {
if (cin.eof())
break;
if (s.size() % 2) {
cout << "NA" << endl;
continue;
}
bool t = false;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] - '0' >= 0 && s[i] - '0' <= 6 && s[i + 1] - '0' >= 0 &&
s[i + 1] - '0' <= 5) {
} else
t = true;
}
if (t) {
cout << "NA" << endl;
continue;
}
for (int i = 0; i < s.size(); i += 2)
cout << table[s[i + 1] - '0' - 1][s[i] - '0' - 1];
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
char table[5][6] = {{'a', 'f', 'k', 'p', 'u', 'z'},
{'b', 'g', 'l', 'q', 'v', '.'},
{'c', 'h', 'm', 'r', 'w', '?'},
{'d', 'i', 'n', 's', 'x', '!'},
{'e', 'j', 'o', 't', 'y', ' '}};
main() {
string s;
while (cin >> s) {
if (cin.eof())
break;
if (s.size() % 2) {
cout << "NA" << endl;
continue;
}
bool t = false;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] - '0' >= 1 && s[i] - '0' <= 6 && s[i + 1] - '0' >= 1 &&
s[i + 1] - '0' <= 5) {
} else
t = true;
}
if (t) {
cout << "NA" << endl;
continue;
}
for (int i = 0; i < s.size(); i += 2)
cout << table[s[i + 1] - '0' - 1][s[i] - '0' - 1];
cout << endl;
}
}
|
[["-", 51, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 347
| 4
|
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
char w[8][7] = {{"abcde"}, {"fghij"}, {"klmno"},
{"pqrst"}, {"uvwxy"}, {"z.?! "}};
string st;
while (cin >> st) {
bool f = true;
char W[200] = {};
if (st.size() % 2 == 1)
cout << "NA" << endl;
else {
for (int i = 0; i < (st.size()); i += 2) {
int x = st[i] - '0' - 1;
int y = st[i + 1] - '0' - 1;
W[i / 2] = w[x][y];
if (x > 4 || x < 0 || y > 4 || y < 0)
f = false;
}
if (f == false)
cout << "NA" << endl;
else
cout << W << endl;
}
}
return 0;
}
|
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
char w[8][7] = {{"abcde"}, {"fghij"}, {"klmno"},
{"pqrst"}, {"uvwxy"}, {"z.?! "}};
string st;
while (cin >> st) {
bool f = true;
char W[200] = {};
if (st.size() % 2 == 1)
cout << "NA" << endl;
else {
for (int i = 0; i < (st.size()); i += 2) {
int x = st[i] - '0' - 1;
int y = st[i + 1] - '0' - 1;
W[i / 2] = w[x][y];
if (x > 5 || x < 0 || y > 4 || y < 0)
f = false;
}
if (f == false)
cout << "NA" << endl;
else
cout << W << endl;
}
}
return 0;
}
|
[["-", 51, 16, 31, 16, 31, 16, 31, 16, 12, 13], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 12, 13]]
| 1
| 225
| 2
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <cmath>
#include <list>
#include <cstdlib>
#include <set>
using namespace std;
int in() {
int x;
cin >> x;
return x;
}
template <typename T>
class SegTree
{
public:
int n;
T T_max;
vector<T> dat;
SegTree(int n_, T t_max)
{
int n = 1;
T_max = t_max;
while (n < n_)
n *= 2;
for (int i = 0; i < 2 * n - 1; i++)
dat.push_back(t_max);
}
void update(int k, T a)
{
k += n - 1;
dat[k] = a;
while (k > 0)
{
k = (k - 1) / 2;
dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)
T query(int a, int b)
{
return _query(a, b, 0, 0, n);
}
private:
T _query(int a, int b, int k, int l, int r)
{
if (r <= a || b <= l)
return T_max;
if (a <= l && r <= b)
return dat[k];
else
{
T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
return min(vr, vl);
}
}
};
int main() {
string a = " abcdefghijklmnopqrstuvwxyz.?! ";
string b;
while (cin >> b) {
string ans;
if (b.size() % 2) {
cout << "NA" << endl;
continue;
}
for (int i = 0; i < b.size(); i += 2) {
int A = b[i] - '0';
int B = b[i + 1] - '0';
if (A < 0 || A > 6) {
ans = "NA";
break;
}
if (B < 0 || B > 5) {
ans = "NA";
break;
}
A--;
int C = A * 5 + B;
if (C > 30) {
ans = "NA";
break;
}
ans += a[C];
}
cout << ans << endl;
}
}
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <cmath>
#include <list>
#include <cstdlib>
#include <set>
using namespace std;
int in() {
int x;
cin >> x;
return x;
}
template <typename T>
class SegTree
{
public:
int n;
T T_max;
vector<T> dat;
SegTree(int n_, T t_max)
{
int n = 1;
T_max = t_max;
while (n < n_)
n *= 2;
for (int i = 0; i < 2 * n - 1; i++)
dat.push_back(t_max);
}
void update(int k, T a)
{
k += n - 1;
dat[k] = a;
while (k > 0)
{
k = (k - 1) / 2;
dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
//[a,b)
T query(int a, int b)
{
return _query(a, b, 0, 0, n);
}
private:
T _query(int a, int b, int k, int l, int r)
{
if (r <= a || b <= l)
return T_max;
if (a <= l && r <= b)
return dat[k];
else
{
T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
return min(vr, vl);
}
}
};
int main() {
string a = " abcdefghijklmnopqrstuvwxyz.?! ";
string b;
while (cin >> b) {
string ans;
if (b.size() % 2) {
cout << "NA" << endl;
continue;
}
for (int i = 0; i < b.size(); i += 2) {
int A = b[i] - '0';
int B = b[i + 1] - '0';
if (A < 0 || A > 6) {
ans = "NA";
break;
}
if (B < 0 || B > 5) {
ans = "NA";
break;
}
A--;
int C = A * 5 + B;
if (C > 30 || C <= 0) {
ans = "NA";
break;
}
ans += a[C];
}
cout << ans << endl;
}
}
|
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 501
| 4
|
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)
char c[201], d[101];
int main() {
while (~scanf("%s", c)) {
if (strlen(c) % 2 == 1) {
printf("NA\n");
} else {
bool flag = false;
for (int i = 0; i < strlen(c); i += 2) {
int a = c[i] - 48, b = c[i + 1] - 48;
if (a == 0 || a > 6 || b == 0 || b > 5) {
printf("NA");
flag = true;
break;
} else {
int e = (a - 1) * 5 + (b - 1);
switch (e) {
case 26:
d[i / 2] = '.';
break;
case 27:
d[i / 2] - '?';
break;
case 28:
d[i / 2] = '!';
break;
case 29:
d[i / 2] = ' ';
break;
default:
d[i / 2] = (char)(e + 97);
}
}
}
if (!flag) {
for (int i = 0; i < strlen(c) / 2; i++) {
printf("%c", d[i]);
}
}
printf("\n");
}
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)
char c[201], d[101];
int main() {
while (~scanf("%s", c)) {
if (strlen(c) % 2 == 1) {
printf("NA\n");
} else {
bool flag = false;
for (int i = 0; i < strlen(c); i += 2) {
int a = c[i] - 48, b = c[i + 1] - 48;
if (a == 0 || a > 6 || b == 0 || b > 5) {
printf("NA");
flag = true;
break;
} else {
int e = (a - 1) * 5 + (b - 1);
switch (e) {
case 26:
d[i / 2] = '.';
break;
case 27:
d[i / 2] = '?';
break;
case 28:
d[i / 2] = '!';
break;
case 29:
d[i / 2] = ' ';
break;
default:
d[i / 2] = (char)(e + 97);
break;
}
}
}
if (!flag) {
for (int i = 0; i < strlen(c) / 2; i++) {
printf("%c", d[i]);
}
}
printf("\n");
}
}
return 0;
}
|
[["-", 8, 9, 0, 100, 0, 1, 0, 16, 17, 33], ["+", 8, 9, 0, 100, 0, 1, 0, 11, 17, 32], ["+", 0, 99, 8, 9, 0, 100, 0, 1, 0, 35], ["+", 0, 99, 8, 9, 0, 100, 0, 93, 0, 94]]
| 1
| 298
| 4
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
string ans, s;
string table[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
int main() {
while (cin >> s) {
bool f = 0;
ans = "";
if (s.size() % 2 != 0) {
cout << "NA" << endl;
continue;
}
if (s.size() == 0)
cout << "NA" << endl;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] > '6' || s[i] < '1' || s[i + 1] > '6' || s[i] < '1')
f = 1;
ans += table[s[i + 1] - '1'][s[i] - '1'];
}
if (f)
cout << "NA" << endl;
else
cout << ans << endl;
ans.clear();
}
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
string ans, s;
string table[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
int main() {
while (cin >> s) {
bool f = 0;
ans = "";
if (s.size() % 2 != 0) {
cout << "NA" << endl;
continue;
}
if (s.size() == 0)
cout << "NA" << endl;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] > '6' || s[i] < '1' || s[i + 1] > '5' || s[i] < '1') {
f = 1;
break;
}
ans += table[s[i + 1] - '1'][s[i] - '1'];
}
if (f)
cout << "NA" << endl;
else
cout << ans << endl;
ans.clear();
}
}
|
[["-", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125], ["+", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
| 1
| 323
| 6
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
char poke[6][6] = {{"abcde"}, {"fghij"}, {"klmno"},
{"pqrst"}, {"uvwxy"}, {"z.?! "}};
while (cin >> str) {
if (str.size() % 2 != 0)
cout << "NA" << endl;
else {
string ans;
bool kawa = 0;
for (int i = 1; i < str.size(); i += 2) {
if (str[i - 1] - '1' < 0 || str[i - 1] - '1' > 5 || str[i] - '1' < 0 ||
str[i] - '1' > 5) {
kawa = 1;
break;
} else
ans += poke[str[i - 1] - '1'][str[i] - '1'];
}
if (kawa)
cout << "NA" << endl;
else
cout << ans << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
char poke[6][6] = {{"abcde"}, {"fghij"}, {"klmno"},
{"pqrst"}, {"uvwxy"}, {"z.?! "}};
while (cin >> str) {
if (str.size() % 2 != 0)
cout << "NA" << endl;
else {
string ans;
bool kawa = 0;
for (int i = 1; i < str.size(); i += 2) {
if (str[i - 1] - '1' < 0 || str[i - 1] - '1' > 5 || str[i] - '1' < 0 ||
str[i] - '1' > 4) {
kawa = 1;
break;
} else
ans += poke[str[i - 1] - '1'][str[i] - '1'];
}
if (kawa)
cout << "NA" << endl;
else
cout << ans << endl;
}
}
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 229
| 2
|
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on
void solve() {
string t[] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
string s;
while (cin >> s) {
if (odd(s.size())) {
cout << "NA" << endl;
continue;
}
stringstream ss;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] < '1' || '6' < s[i] || s[i + 1] < '1' || '6' < s[i + 1]) {
cout << "NA" << endl;
goto next;
}
ss << t[s[i] - '1'][s[i + 1] - '1'];
}
cout << ss.str() << endl;
next:;
}
}
|
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on
void solve() {
string t[] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
string s;
while (cin >> s) {
if (odd(s.size())) {
cout << "NA" << endl;
continue;
}
stringstream ss;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] < '1' || '6' < s[i] || s[i + 1] < '1' || '5' < s[i + 1]) {
cout << "NA" << endl;
goto next;
}
ss << t[s[i] - '1'][s[i + 1] - '1'];
}
cout << ss.str() << endl;
next:;
}
}
|
[["-", 15, 339, 51, 16, 12, 16, 31, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 31, 103, 0, 125]]
| 1
| 516
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str[6] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
string str2;
while (cin >> str2) {
if (str2.size() % 2 == 1)
cout << "NA" << endl;
else {
string ans = "";
for (int i = 0; i < str2.size(); i += 2) {
if (str2[i + 1] - '0' <= 5 && str2[i] - '0' <= 6 &&
str2[i + 1] - '0' > 0 && str2[i] - '0' > 0) {
ans += str[str2[i + 1] - '0' - 1][str2[i] - '0' - 1];
} else {
ans = "NA";
}
}
cout << ans << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str[6] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
string str2;
while (cin >> str2) {
if (str2.size() % 2 == 1)
cout << "NA" << endl;
else {
string ans = "";
for (int i = 0; i < str2.size(); i += 2) {
if (str2[i + 1] - '0' <= 5 && str2[i] - '0' <= 6 &&
str2[i + 1] - '0' > 0 && str2[i] - '0' > 0) {
ans += str[str2[i + 1] - '0' - 1][str2[i] - '0' - 1];
} else {
ans = "NA";
break;
}
}
cout << ans << endl;
}
}
return 0;
}
|
[["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 94], ["+", 0, 57, 75, 76, 0, 9, 0, 93, 0, 35]]
| 1
| 201
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
char tb[9][9];
for (int i = 1; i <= 7; i++)
for (int j = 1; j <= 6; j++)
tb[i][j] = 'a' + (5 * (i - 1) + j - 1);
tb[6][2] = '.';
tb[6][3] = '?';
tb[6][4] = '!';
tb[6][5] = ' ';
string b;
while (cin >> b) {
string res;
bool g = true;
if (b.size() % 2 == 1)
g = false;
else {
for (int i = 0; i < b.size(); i += 2) {
int f = b[i] - '0', s = b[i + 1] - '0';
if (f < 1 && f > 6 || s < 1 && s > 5) {
g = false;
break;
}
res += tb[f][s];
}
}
if (g)
cout << res << endl;
else
cout << "NA" << endl;
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
char tb[9][9];
for (int i = 1; i <= 7; i++)
for (int j = 1; j <= 6; j++)
tb[i][j] = 'a' + (5 * (i - 1) + j - 1);
tb[6][2] = '.';
tb[6][3] = '?';
tb[6][4] = '!';
tb[6][5] = ' ';
string b;
while (cin >> b) {
string res;
bool g = true;
if (b.size() % 2 == 1)
g = false;
else {
for (int i = 0; i < b.size(); i += 2) {
int f = b[i] - '0', s = b[i + 1] - '0';
if (f < 1 || f > 6 || s < 1 || s > 5) {
g = false;
break;
}
res += tb[f][s];
}
}
if (g)
cout << res << endl;
else
cout << "NA" << endl;
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 98], ["+", 15, 339, 51, 16, 31, 16, 31, 16, 17, 106], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 98], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106]]
| 1
| 264
| 4
|
#include <iostream>
#include <string>
using namespace std;
int main(void) {
const char *table[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
while (true) {
bool bNA = false;
string s;
cin >> s;
if (cin.eof())
break;
if (s.length() % 2 == 1) {
bNA = true;
goto NA;
}
for (unsigned int l = 0; l < s.length(); l += 2) {
int i = s[l + 1] - '0' - 1;
int j = s[l] - '0' - 1;
if (!(0 <= i && i <= 5) || !(0 <= j && j <= 6)) {
bNA = true;
goto NA;
}
}
NA:;
if (bNA) {
cout << "NA\n";
continue;
}
for (unsigned int l = 0; l < s.length(); l += 2) {
int i = s[l + 1] - '0' - 1;
int j = s[l] - '0' - 1;
cout << table[i][j];
}
cout << '\n';
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main(void) {
const char *table[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
while (true) {
bool bNA = false;
string s;
cin >> s;
if (cin.eof())
break;
if (s.length() % 2 == 1) {
bNA = true;
goto NA;
}
for (unsigned int l = 0; l < s.length(); l += 2) {
int i = s[l + 1] - '0' - 1;
int j = s[l] - '0' - 1;
if (!(0 <= i && i <= 4) || !(0 <= j && j <= 5)) {
bNA = true;
goto NA;
}
}
NA:;
if (bNA) {
cout << "NA\n";
continue;
}
for (unsigned int l = 0; l < s.length(); l += 2) {
int i = s[l + 1] - '0' - 1;
int j = s[l] - '0' - 1;
cout << table[i][j];
}
cout << '\n';
}
return 0;
}
|
[["-", 31, 91, 28, 23, 0, 16, 12, 16, 12, 13], ["+", 31, 91, 28, 23, 0, 16, 12, 16, 12, 13], ["-", 12, 91, 28, 23, 0, 16, 12, 16, 12, 13], ["+", 12, 91, 28, 23, 0, 16, 12, 16, 12, 13]]
| 1
| 267
| 4
|
#include <iostream>
using namespace std;
char s[6][6] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
int main(void) {
string str;
while (cin >> str) {
if (str.length() % 2 == 1) {
cout << "NA\n";
continue;
}
string ans = "";
bool flg = false;
for (int i = 0; i < str.length(); i += 2) {
if ('1' > str[i] || str[i] >= '7' || '1' > str[i + 1] ||
str[i + 1] >= '7') {
cout << "NA\n";
flg = true;
break;
}
int a = str[i] - '1';
int b = str[i + 1] - '1';
ans += s[a][b];
}
if (flg)
continue;
cout << ans << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
char s[6][6] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
int main(void) {
string str;
while (cin >> str) {
if (str.length() % 2 == 1) {
cout << "NA\n";
continue;
}
string ans = "";
bool flg = false;
for (int i = 0; i < str.length(); i += 2) {
if ('1' > str[i] || str[i] >= '7' || '1' > str[i + 1] ||
str[i + 1] >= '6') {
cout << "NA\n";
flg = true;
break;
}
int a = str[i] - '1';
int b = str[i + 1] - '1';
ans += s[a][b];
}
if (flg)
continue;
cout << ans << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 222
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string nums, text, ch;
ch = "abcdefghijklmnopqrstuvwxyz.?! ";
while (cin >> nums) {
text = "";
if (nums.size() % 2) {
cout << "NA" << endl;
} else {
for (int i = 0; i < nums.size() / 2; i++) {
if ('0' < nums[i * 2] && nums[i * 2] < '7' && '0' < nums[i * 2 + 1] &&
nums[i * 2 + 1] < '7')
text = text + ch[5 * (nums[i * 2] - 49) + (nums[i * 2 + 1] - 49)];
else {
text = "NA";
break;
}
}
cout << text << endl;
}
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string nums, text, ch;
ch = "abcdefghijklmnopqrstuvwxyz.?! ";
while (cin >> nums) {
text = "";
if (nums.size() % 2) {
cout << "NA" << endl;
} else {
for (int i = 0; i < nums.size() / 2; i++) {
if ('0' < nums[i * 2] && nums[i * 2] < '7' && '0' < nums[i * 2 + 1] &&
nums[i * 2 + 1] < '6')
text = text + ch[5 * (nums[i * 2] - 49) + (nums[i * 2 + 1] - 49)];
else {
text = "NA";
break;
}
}
cout << text << endl;
}
}
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 188
| 2
|
#include <iostream>
#include <string>
using namespace std;
string mp[6] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
int main() {
string s;
while (cin >> s) {
if (s.length() % 2) {
cout << "NA" << endl;
continue;
}
string res = "";
for (int i = 0; i < s.length(); i += 2) {
if (s[i] >= '7' || s[i] <= '0' || s[i + 1] >= '7' || s[i + 1] <= '0') {
cout << "NA" << endl;
goto NEXT;
}
res += string(1, mp[s[i] - '1'][s[i + 1] - '1']);
}
cout << res << endl;
NEXT:;
}
}
|
#include <iostream>
#include <string>
using namespace std;
string mp[6] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
int main() {
string s;
while (cin >> s) {
if (s.length() % 2) {
cout << "NA" << endl;
continue;
}
string res = "";
for (int i = 0; i < s.length(); i += 2) {
if (s[i] >= '7' || s[i] <= '0' || s[i + 1] >= '6' || s[i + 1] <= '0') {
cout << "NA" << endl;
goto NEXT;
}
res += string(1, mp[s[i] - '1'][s[i + 1] - '1']);
}
cout << res << endl;
NEXT:;
}
}
|
[["-", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125], ["+", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 201
| 2
|
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
string a = "afkpu";
int main(void) {
string line;
while (cin >> line) {
string ans;
bool na = false;
if (line.size() % 2) {
na = true;
}
for (int i = 0; i < (int)line.size(); i += 2) {
if (na)
break;
if (line[i + 1] >= '7' || line[i + 1] <= '0') {
na = true;
break;
}
if (line[i] <= '5') {
ans += (char)(a[line[i] - '1'] + line[i + 1] - '1');
} else if (line[i] == '6') {
if (line[i + 1] == '1')
ans += 'z';
if (line[i + 1] == '2')
ans += '.';
if (line[i + 1] == '3')
ans += '?';
if (line[i + 1] == '4')
ans += '!';
if (line[i + 1] == '5')
ans += ' ';
} else {
na = true;
break;
}
}
if (!na)
cout << ans << endl;
else
cout << "NA" << endl;
}
return 0;
}
|
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
string a = "afkpu";
int main(void) {
string line;
while (cin >> line) {
string ans;
bool na = false;
if (line.size() % 2) {
na = true;
}
for (int i = 0; i < (int)line.size(); i += 2) {
if (na)
break;
if (line[i + 1] >= '6' || line[i + 1] <= '0') {
na = true;
break;
}
if (line[i] <= '5') {
ans += (char)(a[line[i] - '1'] + line[i + 1] - '1');
} else if (line[i] == '6') {
if (line[i + 1] == '1')
ans += 'z';
if (line[i + 1] == '2')
ans += '.';
if (line[i + 1] == '3')
ans += '?';
if (line[i + 1] == '4')
ans += '!';
if (line[i + 1] == '5')
ans += ' ';
} else {
na = true;
break;
}
}
if (!na)
cout << ans << endl;
else
cout << "NA" << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 31, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 31, 16, 12, 103, 0, 125]]
| 1
| 378
| 2
|
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char c[] = {'z', '.', '?', '!', ' '};
string s;
int main() {
while (getline(cin, s)) {
int l = s.size();
if (l % 2) {
cout << "NA" << endl;
continue;
}
int cur = 0, f = 0;
string ans = "";
while (cur < l) {
int a = s[cur++] - '0', b = s[cur++] - '0';
if (a < 1 || a > 6 || b < 1 || b > 5) {
cout << "NA" << endl;
f = 1;
continue;
}
if (a < 6)
ans += (char)('a' + (a - 1) * 5 + b - 1);
if (a == 6)
ans += c[b - 1];
}
if (!f)
cout << ans << endl;
}
}
|
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char c[] = {'z', '.', '?', '!', ' '};
string s;
int main() {
while (getline(cin, s)) {
int l = s.size();
if (l % 2) {
cout << "NA" << endl;
continue;
}
int cur = 0, f = 0;
string ans = "";
while (cur < l) {
int a = s[cur++] - '0', b = s[cur++] - '0';
if (a < 1 || a > 6 || b < 1 || b > 5) {
cout << "NA" << endl;
f = 1;
break;
}
if (a < 6)
ans += (char)('a' + (a - 1) * 5 + b - 1);
if (a == 6)
ans += c[b - 1];
}
if (!f)
cout << ans << endl;
}
}
|
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
| 1
| 241
| 2
|
#include <iostream>
#include <string>
#define rep(i, x) for (int i = 0; i < x; i++)
using namespace std;
string s;
char tab[10][10] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "x.?! "};
void solve() {
int n = 0, k = 0;
char ans[1000];
if (s.size() % 2 != 0) {
cout << "NA" << endl;
return;
} else {
while (n < s.size()) {
if (s[n] >= '1' && s[n] < '7' && s[n + 1] >= '1' && s[n + 1] < '6')
ans[k++] = tab[s[n] - 1 - '0'][s[n + 1] - 1 - '0'];
else {
cout << "NA" << endl;
return;
}
n += 2;
}
rep(i, k) cout << ans[i];
cout << endl;
}
}
int main() {
while (cin >> s) {
solve();
}
return 0;
}
|
#include <iostream>
#include <string>
#define rep(i, x) for (int i = 0; i < x; i++)
using namespace std;
string s;
char tab[10][10] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
void solve() {
int n = 0, k = 0;
char ans[1000];
if (s.size() % 2 != 0) {
cout << "NA" << endl;
return;
} else {
while (n < s.size()) {
if (s[n] >= '1' && s[n] < '7' && s[n + 1] >= '1' && s[n + 1] < '6')
ans[k++] = tab[s[n] - 1 - '0'][s[n + 1] - 1 - '0'];
else {
cout << "NA" << endl;
return;
}
n += 2;
}
rep(i, k) cout << ans[i];
cout << endl;
}
}
int main() {
while (cin >> s) {
solve();
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6], ["+", 0, 43, 49, 50, 51, 83, 0, 5, 0, 6]]
| 1
| 245
| 2
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
char table[20][20];
string str;
for (int i = 1; i <= 6; i++) {
for (int j = 1; j <= 5; j++) {
table[j][i] = 'a' + 5 * (i - 1) + (j - 1);
if (i == 6 && j == 1)
break;
}
if (i == 6) {
table[2][6] = '.';
table[3][6] = '?';
table[4][6] = '!';
table[5][6] = ' ';
}
}
while (cin >> str) {
if (str.size() % 2 == 1) {
cout << "NA" << endl;
continue;
}
bool f = false;
string cs;
for (int i = 0; i < str.size(); i += 2) {
if (str[i] >= '1' && str[i] <= '6' && str[i + 1] >= '1' &&
str[i + 1] <= '6') {
cs += table[str[i + 1] - '0'][str[i] - '0'];
} else {
f = true;
cout << "NA" << endl;
break;
}
}
if (f)
continue;
else {
cout << cs << endl;
}
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
char table[20][20];
string str;
for (int i = 1; i <= 6; i++) {
for (int j = 1; j <= 5; j++) {
table[j][i] = 'a' + 5 * (i - 1) + (j - 1);
if (i == 6 && j == 1)
break;
}
if (i == 6) {
table[2][6] = '.';
table[3][6] = '?';
table[4][6] = '!';
table[5][6] = ' ';
}
}
while (cin >> str) {
if (str.size() % 2 == 1) {
cout << "NA" << endl;
continue;
}
bool f = false;
string cs;
for (int i = 0; i < str.size(); i += 2) {
if (str[i] >= '1' && str[i] <= '6' && str[i + 1] >= '1' &&
str[i + 1] <= '5') {
cs += table[str[i + 1] - '0'][str[i] - '0'];
} else {
f = true;
cout << "NA" << endl;
break;
}
}
if (f)
continue;
else {
cout << cs << endl;
}
}
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 322
| 2
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair
template <class T> void pv(T a, T b) {
for (T i = a; i != b; ++i)
cout << *i << " ";
cout << endl;
}
template <class T> void chmin(T &t, T f) {
if (t > f)
t = f;
}
template <class T> void chmax(T &t, T f) {
if (t < f)
t = f;
}
int in() {
int x;
scanf("%d", &x);
return x;
}
int main() {
string str;
while (getline(cin, str)) {
string res = "";
int i;
if (str.size() % 2 == 0) {
cout << "NA" << endl;
continue;
}
for (i = 0; i < str.size() - 2; i += 2) {
if (str[i] < '1' || '6' < str[i] || str[i + 1] < '1' ||
'5' < str[i + 1]) {
cout << "NA" << endl;
goto a;
}
if (str[i] != '6') {
res += 'a' + (str[i] - '1') * 5 + str[i + 1] - '1';
} else {
switch (str[i + 1]) {
case '1':
res += "z";
break;
case '2':
res += ".";
break;
case '3':
res += "?";
break;
case '4':
res += "!";
break;
case '5':
res += " ";
break;
}
}
}
cout << res << endl;
a:;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair
template <class T> void pv(T a, T b) {
for (T i = a; i != b; ++i)
cout << *i << " ";
cout << endl;
}
template <class T> void chmin(T &t, T f) {
if (t > f)
t = f;
}
template <class T> void chmax(T &t, T f) {
if (t < f)
t = f;
}
int in() {
int x;
scanf("%d", &x);
return x;
}
int main() {
string str;
while (getline(cin, str)) {
string res = "";
int i;
if (str.size() % 2 > 0) {
cout << "NA" << endl;
continue;
}
for (i = 0; i < str.size(); i += 2) {
if (str[i] < '1' || '6' < str[i] || str[i + 1] < '1' ||
'5' < str[i + 1]) {
cout << "NA" << endl;
goto a;
}
if (str[i] != '6') {
res += 'a' + (str[i] - '1') * 5 + str[i + 1] - '1';
} else {
switch (str[i + 1]) {
case '1':
res += "z";
break;
case '2':
res += ".";
break;
case '3':
res += "?";
break;
case '4':
res += "!";
break;
case '5':
res += " ";
break;
}
}
}
cout << res << endl;
a:;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 445
| 4
|
#include <iostream>
using namespace std;
int main() {
char g[42] = {97, 102, 107, 112, 117, 122, 98, 103, 108, 113,
118, 46, 99, 104, 109, 114, 119, 63, 100, 105,
110, 115, 120, 33, 101, 106, 111, 116, 121, 32};
string s, a;
while (cin >> s, !cin.eof()) {
for (int i = 0; i < s.size(); i += 2) {
int l = s[i] - '0', r = s[i + 1] - '0';
if (s.size() % 2 || l < 1 || r < 1 || l > 6 || r > 5) {
a = "NA";
break;
}
a += g[r * 6 + l - 7];
}
cout << a << endl;
}
}
|
#include <iostream>
using namespace std;
main() {
char g[42] = {97, 102, 107, 112, 117, 122, 98, 103, 108, 113,
118, 46, 99, 104, 109, 114, 119, 63, 100, 105,
110, 115, 120, 33, 101, 106, 111, 116, 121, 32};
string s, a;
while (cin >> s, !cin.eof()) {
a = "";
for (int i = 0; i < s.size(); i += 2) {
int l = s[i] - '0', r = s[i + 1] - '0';
if (s.size() % 2 || l < 1 || r < 1 || l > 6 || r > 5) {
a = "NA";
break;
}
a += g[r * 6 + l - 7];
}
cout << a << endl;
}
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 62], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 201
| 6
|
#include <iostream>
using namespace std;
char table[6][5] = {
{'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
{'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
{'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '}};
int temp[2];
int main() {
string mes;
while (cin >> mes) {
if (mes.length() % 2 != 0)
cout << "NA" << endl;
else {
string res = "";
bool flag = false;
for (int i = 0; i < mes.length(); i++) {
if (i % 2 != 0) {
temp[1] = mes[i] - '0';
if (temp[0] < 1 || temp[1] < 1 || temp[0] > 6 || temp[1] > 6) {
flag = true;
break;
} else {
res += table[temp[0] - 1][temp[1] - 1];
}
} else
temp[0] = mes[i] - '0';
}
if (flag)
cout << "NA" << endl;
else
cout << res << endl;
}
}
}
|
#include <iostream>
using namespace std;
char table[6][5] = {
{'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
{'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
{'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '}};
int temp[2];
int main() {
string mes;
while (cin >> mes) {
if (mes.length() % 2 != 0)
cout << "NA" << endl;
else {
string res = "";
bool flag = false;
for (int i = 0; i < mes.length(); i++) {
if (i % 2 != 0) {
temp[1] = mes[i] - '0';
if (temp[0] < 1 || temp[1] < 1 || temp[0] > 6 || temp[1] > 5) {
flag = true;
break;
} else {
res += table[temp[0] - 1][temp[1] - 1];
}
} else
temp[0] = mes[i] - '0';
}
if (flag)
cout << "NA" << endl;
else
cout << res << endl;
}
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 345
| 2
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T> T RoundOff(T a) { return int(a + .5 - (a < 0)); }
template <class T, class C> void chmax(T &a, C b) {
if (a < b)
a = b;
}
template <class T, class C> void chmin(T &a, C b) {
if (b < a)
a = b;
}
template <class T, class C> pair<T, C> mp(T a, C b) { return make_pair(a, b); }
int main() {
string table[6] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
for (string line; cin >> line;) {
if (line.size() % 2) {
cout << "NA" << endl;
continue;
}
string ans;
rep(i, line.size() / 2) if ('0' < line[i * 2] && line[i * 2] <= '6' &&
'0' < line[i * 2 + 1] && line[i * 2 + 1] <= '6')
ans += table[line[i * 2] - '1'][line[i * 2 + 1] - '1'];
if (ans.size() * 2 == line.size())
cout << ans << endl;
else
cout << "NA" << endl;
}
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T> T RoundOff(T a) { return int(a + .5 - (a < 0)); }
template <class T, class C> void chmax(T &a, C b) {
if (a < b)
a = b;
}
template <class T, class C> void chmin(T &a, C b) {
if (b < a)
a = b;
}
template <class T, class C> pair<T, C> mp(T a, C b) { return make_pair(a, b); }
int main() {
string table[6] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
for (string line; cin >> line;) {
if (line.size() % 2) {
cout << "NA" << endl;
continue;
}
string ans;
rep(i, line.size() / 2) if ('1' <= line[i * 2] && line[i * 2] <= '6' &&
'1' <= line[i * 2 + 1] &&
line[i * 2 + 1] <= '5') ans +=
table[line[i * 2] - '1'][line[i * 2 + 1] - '1'];
if (ans.size() * 2 == line.size())
cout << ans << endl;
else
cout << "NA" << endl;
}
}
|
[["-", 31, 16, 31, 16, 31, 16, 31, 103, 0, 125], ["+", 31, 16, 31, 16, 31, 16, 31, 103, 0, 125], ["-", 51, 16, 31, 16, 31, 16, 31, 16, 17, 18], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 17, 19], ["-", 51, 16, 31, 16, 12, 16, 31, 103, 0, 125], ["+", 51, 16, 31, 16, 12, 16, 31, 103, 0, 125], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 18], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 19], ["-", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125], ["+", 15, 339, 51, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 425
| 10
|
#include <iostream>
using namespace std;
char table[5][6] = {
{'a', 'f', 'k', 'p', 'u', 'z'},
{'b', 'g', 'l', 'q', 'v', '.'},
{'c', 'h', 'm', 'r', 'w', '?'},
{'d', 'i', 'n', 's', 'x', '!'},
{'e', 'j', 'o', 't', 'y', ' '}
};
int main() {
string buf;
while (getline(cin, buf)) {
if (buf.size() % 2 == 1)
goto NA;
for (int i = 0; i < buf.size(); i++) {
if (i % 2 == 0 && (buf[i] - '0') < 1 && (buf[i] - '0') > 6)
goto NA;
if (i % 2 == 1 && (buf[i] - '0') < 1 && (buf[i] - '0') > 5)
goto NA;
}
for (int i = 0; i < buf.size() / 2; i++) {
cout << table[(buf[2 * i + 1] - '0' - 1)][(buf[2 * i] - '0' - 1)];
}
cout << endl;
continue;
NA:
cout << "NA" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
char table[5][6] = {
{'a', 'f', 'k', 'p', 'u', 'z'},
{'b', 'g', 'l', 'q', 'v', '.'},
{'c', 'h', 'm', 'r', 'w', '?'},
{'d', 'i', 'n', 's', 'x', '!'},
{'e', 'j', 'o', 't', 'y', ' '}
};
int main() {
string buf;
while (getline(cin, buf)) {
if (buf.size() % 2 == 1)
goto NA;
for (int i = 0; i < buf.size(); i++) {
if (i % 2 == 0 && ((buf[i] - '0') < 1 || (buf[i] - '0') > 6))
goto NA;
if (i % 2 == 1 && ((buf[i] - '0') < 1 || (buf[i] - '0') > 5))
goto NA;
}
for (int i = 0; i < buf.size() / 2; i++) {
cout << table[(buf[2 * i + 1] - '0' - 1)][(buf[2 * i] - '0' - 1)];
}
cout << endl;
continue;
NA:
cout << "NA" << endl;
}
return 0;
}
|
[["+", 12, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 25], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24]]
| 1
| 355
| 8
|
#include <iostream>
#include <string>
using namespace std;
int main() {
char map[6][5] = {{'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
{'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
{'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '}};
string s;
while (cin >> s) {
bool err = false;
for (int i = 0; i < s.size(); i++) {
if (i % 2 && (s[i] > '5' || s[i] < '0'))
err = true;
else if (i % 2 == 0 && (s[i] > '6' || s[i] < '0'))
err = true;
}
if (s.size() % 2 || err)
cout << "NA" << endl;
else {
for (int i = 0; i < s.size(); i += 2) {
cout << map[s[i] - '0' - 1][s[i + 1] - '0' - 1];
}
cout << endl;
}
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
char map[6][5] = {{'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
{'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
{'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '}};
string s;
while (cin >> s) {
bool err = false;
for (int i = 0; i < s.size(); i++) {
if (i % 2 && (s[i] > '5' || s[i] < '1'))
err = true;
else if (i % 2 == 0 && (s[i] > '6' || s[i] < '1'))
err = true;
}
if (s.size() % 2 || err)
cout << "NA" << endl;
else {
for (int i = 0; i < s.size(); i += 2) {
cout << map[s[i] - '0' - 1][s[i + 1] - '0' - 1];
}
cout << endl;
}
}
}
|
[["-", 12, 23, 0, 16, 12, 16, 12, 103, 0, 125], ["+", 12, 23, 0, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 334
| 10
|
#include <cstdio>
#include <iostream>
using namespace std;
const string hyou[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
int main() {
string in;
while (cin >> in) {
cin.ignore();
if (in.size() % 2 == 1) {
cout << "NA" << endl;
continue;
}
bool flag = true;
string ans = "";
for (int i = 0; i < in.size() - 1; i += 2) {
if (!('1' <= in[i + 1] && in[i + 1] <= '6') ||
!('1' <= in[i] && in[i] <= '6')) {
flag = false;
break;
}
ans += hyou[in[i + 1] - '0' - 1][in[i] - '0' - 1];
}
if (flag)
cout << ans << endl;
else
cout << "NA" << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
const string hyou[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};
int main() {
string in;
while (cin >> in) {
cin.ignore();
if (in.size() % 2 == 1) {
cout << "NA" << endl;
continue;
}
bool flag = true;
string ans = "";
for (int i = 0; i < in.size() - 1; i += 2) {
if (!('1' <= in[i + 1] && in[i + 1] <= '5') ||
!('1' <= in[i] && in[i] <= '6')) {
flag = false;
break;
}
ans += hyou[in[i + 1] - '0' - 1][in[i] - '0' - 1];
}
if (flag)
cout << ans << endl;
else
cout << "NA" << endl;
}
return 0;
}
|
[["-", 28, 23, 0, 16, 12, 16, 12, 103, 0, 125], ["+", 28, 23, 0, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 225
| 2
|
#include <iostream>
#include <string>
const char symbol[4] = {'.', '?', '!', ' '};
int main() {
std::string s;
while (std::cin >> s) {
if (s.size() & 1)
std::cout << "NA" << std::endl;
else {
std::string res;
bool f = true;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] < '0' || s[i] > '6' || s[i + 1] < '0' || s[i + 1] > '5') {
f = false;
break;
}
int n = (s[i] - '1') * 5 + s[i + 1] - '1';
if (n > 29) {
f = false;
break;
} else
res += n >= 26 ? symbol[n - 26] : 'a' + n;
}
std::cout << (f ? res : "NA") << std::endl;
}
}
return 0;
}
|
#include <iostream>
#include <string>
const char symbol[4] = {'.', '?', '!', ' '};
int main() {
std::string s;
while (std::cin >> s) {
if (s.size() & 1)
std::cout << "NA" << std::endl;
else {
std::string res;
bool f = true;
for (int i = 0; i < s.size(); i += 2) {
if (s[i] < '1' || s[i] > '6' || s[i + 1] < '1' || s[i + 1] > '5') {
f = false;
break;
}
int n = (s[i] - '1') * 5 + s[i + 1] - '1';
if (n > 29) {
f = false;
break;
} else
res += n >= 26 ? symbol[n - 26] : 'a' + n;
}
std::cout << (f ? res : "NA") << std::endl;
}
}
return 0;
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 31, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["-", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125], ["+", 51, 16, 31, 16, 12, 16, 12, 103, 0, 125]]
| 1
| 238
| 4
|
#include <bits/stdc++.h>
using namespace std;
const string characters = "abcdefghijklmnopqrstuvwxyz.?! ";
string convert(const string &number) {
if (number.size() & 1)
return "NA";
string res = "";
for (unsigned i = 0; i < number.size(); i += 2) {
if (!('1' <= number[i] && number[i] <= '6'))
return "NA";
if (!('1' <= number[i] && number[i] <= '5'))
return "NA";
const unsigned idx = (number[i] - '1') * 5 + (number[i + 1] - '1');
if (idx >= characters.size())
return "NA";
res += characters[idx];
}
return res;
}
int main() {
string number;
while (cin >> number) {
cout << convert(number) << endl;
}
return EXIT_SUCCESS;
}
|
#include <bits/stdc++.h>
using namespace std;
const string characters = "abcdefghijklmnopqrstuvwxyz.?! ";
string convert(const string &number) {
if (number.size() & 1)
return "NA";
string res = "";
for (unsigned i = 0; i < number.size(); i += 2) {
if (!('1' <= number[i] && number[i] <= '6'))
return "NA";
if (!('1' <= number[i + 1] && number[i + 1] <= '5'))
return "NA";
const unsigned idx = (number[i] - '1') * 5 + (number[i + 1] - '1');
if (idx >= characters.size())
return "NA";
res += characters[idx];
}
return res;
}
int main() {
string number;
while (cin >> number) {
cout << convert(number) << endl;
}
return EXIT_SUCCESS;
}
|
[["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 206
| 4
|
#include <iostream>
using namespace std;
int main() {
int i, p, q;
bool b;
char buf[201];
char code[5][6] = {
{'a', 'f', 'k', 'p', 'u', 'z'}, {'b', 'g', 'l', 'l', 'q', 'v'},
{'c', 'h', 'm', 'r', 'w', '?'}, {'d', 'i', 'n', 's', 'x', '!'},
{'e', 'j', 'o', 't', 'y', ' '},
};
while (cin.getline(buf, sizeof(buf))) {
i = 0;
b = true;
while (buf[i] != '\0') {
if (i & 1) {
if (buf[i] < '1' || buf[i] > '5') {
b = false;
break;
}
} else {
if (buf[i] < '1' || buf[i] > '6') {
b = false;
break;
}
}
++i;
}
if (i & 1)
b = false;
if (b) {
i = 0;
while (buf[i] != '\0') {
p = buf[i++] - '1';
q = buf[i++] - '1';
cout << code[q][p];
}
cout << endl;
} else {
cout << "NA" << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int i, p, q;
bool b;
char buf[201];
char code[5][6] = {
{'a', 'f', 'k', 'p', 'u', 'z'}, {'b', 'g', 'l', 'q', 'v', '.'},
{'c', 'h', 'm', 'r', 'w', '?'}, {'d', 'i', 'n', 's', 'x', '!'},
{'e', 'j', 'o', 't', 'y', ' '},
};
while (cin.getline(buf, sizeof(buf))) {
i = 0;
b = true;
while (buf[i] != '\0') {
if (i & 1) {
if (buf[i] < '1' || buf[i] > '5') {
b = false;
break;
}
} else {
if (buf[i] < '1' || buf[i] > '6') {
b = false;
break;
}
}
++i;
}
if (i & 1)
b = false;
if (b) {
i = 0;
while (buf[i] != '\0') {
p = buf[i++] - '1';
q = buf[i++] - '1';
cout << code[q][p];
}
cout << endl;
} else {
cout << "NA" << endl;
}
}
return 0;
}
|
[["-", 49, 50, 51, 83, 0, 83, 0, 103, 0, 125], ["+", 49, 50, 51, 83, 0, 83, 0, 103, 0, 125]]
| 1
| 362
| 6
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char field[6][11];
char a = 'a';
for (int i = 1; i < 7; i++) {
for (int j = 1; j < 6; j++) {
field[j][i] = a;
a++;
}
}
field[2][6] = '.';
field[3][6] = '?';
field[4][6] = '!';
field[5][6] = ' ';
string input;
while (cin >> input) {
string ans;
bool isCorrect = true;
if (input.size() % 2 == 1) {
isCorrect = false;
continue;
} else {
for (int i = 0; i < input.size(); i += 2) {
int n = atoi(input.substr(i, 1).c_str());
int m = atoi(input.substr(i + 1, 1).c_str());
if (!(1 <= m && m <= 5 && 1 <= n && n <= 6))
isCorrect = false;
ans += field[m][n];
}
}
if (isCorrect)
cout << ans << endl;
else
cout << "NA" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char field[6][11];
char a = 'a';
for (int i = 1; i < 7; i++) {
for (int j = 1; j < 6; j++) {
field[j][i] = a;
a++;
}
}
field[2][6] = '.';
field[3][6] = '?';
field[4][6] = '!';
field[5][6] = ' ';
string input;
while (cin >> input) {
string ans;
bool isCorrect = true;
if (input.size() % 2 == 1) {
isCorrect = false;
} else {
for (int i = 0; i < input.size(); i += 2) {
int n = atoi(input.substr(i, 1).c_str());
int m = atoi(input.substr(i + 1, 1).c_str());
if (!(1 <= m && m <= 5 && 1 <= n && n <= 6))
isCorrect = false;
ans += field[m][n];
}
}
if (isCorrect)
cout << ans << endl;
else
cout << "NA" << endl;
}
}
|
[["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]]
| 1
| 278
| 2
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(), (x).end())
#define all(x) (x).begin(), (x).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
int main() {
string s;
while (cin >> s) {
string ans;
int sz = s.size();
if (sz % 2 == 1) {
cout << "NA" << endl;
continue;
}
for (int i = 0; i < sz / 2; i++) {
int f = s[2 * i] - '0', se = s[2 * i + 1] - '0';
if (f < 0 || f > 6 || se < 0 || se > 5) {
cout << "NA" << endl;
goto end;
}
if (f == 6 && se >= 2) {
switch (se) {
case 2:
ans += '.';
break;
case 3:
ans += '?';
break;
case 4:
ans += '!';
break;
case 5:
ans += ' ';
break;
}
} else
ans += 'a' + (f - 1) * 5 + se - 1;
}
cout << ans << endl;
end:;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(), (x).end())
#define all(x) (x).begin(), (x).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
int main() {
string s;
while (cin >> s) {
string ans;
int sz = s.size();
if (sz % 2 == 1) {
cout << "NA" << endl;
continue;
}
for (int i = 0; i < sz / 2; i++) {
int f = s[2 * i] - '0', se = s[2 * i + 1] - '0';
if (f <= 0 || f > 6 || se <= 0 || se > 5) {
cout << "NA" << endl;
goto end;
}
if (f == 6 && se >= 2) {
switch (se) {
case 2:
ans += '.';
break;
case 3:
ans += '?';
break;
case 4:
ans += '!';
break;
case 5:
ans += ' ';
break;
}
} else
ans += 'a' + (f - 1) * 5 + se - 1;
}
cout << ans << endl;
end:;
}
return 0;
}
|
[["-", 51, 16, 31, 16, 31, 16, 31, 16, 17, 18], ["+", 51, 16, 31, 16, 31, 16, 31, 16, 17, 19], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 18], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 19]]
| 1
| 329
| 4
|
def calc (input)
seet = [[nil],
[nil,"a","b","c","d","e"],
[nil,"f","g","h","i","j"],
[nil,"k","l","m","n","o"],
[nil,"p","q","r","s","t"],
[nil,"u","v","w","x","y"],
[nil,"z",".","?","!"," "]
]
input.gsub!(/\n/,"")
no = input.split("")
no = no.map{|n| n.to_i}
if (no.size%2!=0)
return "NA"
end
output = ""
(no.size/2).times do |i|
begin
output = output + seet[no.shift][no.shift]
rescue
return "NA"
end
end
return output
end
input = gets
puts calc(input)
|
def calc (input)
seet = [[nil],
[nil,"a","b","c","d","e"],
[nil,"f","g","h","i","j"],
[nil,"k","l","m","n","o"],
[nil,"p","q","r","s","t"],
[nil,"u","v","w","x","y"],
[nil,"z",".","?","!"," "]
]
input.gsub!(/\n/,"")
no = input.split("")
no = no.map{|n| n.to_i}
if (no.size%2!=0)
return "NA"
end
output = ""
(no.size/2).times do |i|
begin
output = output + seet[no.shift][no.shift]
rescue
return "NA"
end
end
return output
end
while input = gets
puts calc(input)
end
|
[["+", 36, 36, 36, 36, 0, 493, 0, 89, 0, 89], ["+", 36, 36, 0, 493, 0, 89, 8, 170, 0, 444]]
| 4
| 255
| 2
|
def maje_table
i = 0
j = 0
table = Array.new(6)
table.map!{Array.new(5)}
"a".upto("z") do |c|
table[i][j] = c
j += 1
i += 1 if j == 5
j = 0 if j == 5
end
table[5][1] = '.'
table[5][2] = '?'
table[5][3] = '!'
table[5][4] = ' '
table
end
$table = make_table
readlines.each do |input|
message = input.chomp
if message.size.odd?
puts "NA"
next
end
message_int = []
message.chars.map{|x| x.to_i-1}.each_slice(2){ |x| message_int << x }
if message_int.map{ |cons| 0 <= cons.first && cons.first <= 5 && 0 <= cons.last && cons.last <= 4 }.include?(false)
puts "NA"
next
end
message_int.each { |set| print $table[set.first][set.last] }
puts ""
end
|
def make_table
i = 0
j = 0
table = Array.new(6)
table.map!{Array.new(5)}
"a".upto("z") do |c|
table[i][j] = c
j += 1
i += 1 if j == 5
j = 0 if j == 5
end
table[5][1] = '.'
table[5][2] = '?'
table[5][3] = '!'
table[5][4] = ' '
table
end
$table = make_table
readlines.each do |input|
message = input.chomp
if message.size.odd?
puts "NA"
next
end
message_int = []
message.chars.map{|x| x.to_i-1}.each_slice(2){ |x| message_int << x }
if message_int.map{ |cons| 0 <= cons.first && cons.first <= 5 && 0 <= cons.last && cons.last <= 4 }.include?(false)
puts "NA"
next
end
message_int.each { |set| print $table[set.first][set.last] }
puts ""
end
|
[["-", 36, 36, 36, 36, 0, 493, 0, 735, 141, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 735, 141, 22]]
| 4
| 240
| 2
|
import sys
s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
for t in range(1, 6):
d[(str(y),str(t))] = s[0]
s = s[1:]
for line in sys.stdin:
line = line.rstrip()
if len(line) % 2 != 0:
print('NA')
continue
ans = ''
for i in range(0, len(line), 2):
if d[(line[i],line[i+1])]:
ans += d[(line[i],line[i+1])]
else:
print('NA')
break
else:
print(ans)
|
import sys
s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
for t in range(1, 6):
d[(str(y),str(t))] = s[0]
s = s[1:]
for line in sys.stdin:
line = line.rstrip()
if len(line) % 2 != 0:
print('NA')
continue
ans = ''
for i in range(0, len(line), 2):
if (line[i],line[i+1]) in d:
ans += d[(line[i],line[i+1])]
else:
print('NA')
break
else:
print(ans)
|
[["-", 0, 7, 8, 196, 0, 57, 15, 206, 51, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 206, 0, 70], ["-", 0, 7, 8, 196, 0, 57, 15, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 267], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]]
| 5
| 158
| 5
|
# Aizu Problem 00127: Pocket Pager Input
#
import sys, math, os, copy
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
code = {1: "afkpuz", 2: "ablqv.", 3: "chmrw?", 4: "dinsx!", 5: "ejoty "}
def pocket_pager(string):
if len(string) % 2 == 1:
return "NA"
res = ""
for k in range(len(string) // 2):
i = int(string[2*k])
j = int(string[2*k+1])
if not 1 <= i <= 6 or not 1 <= j <= 5:
return "NA"
res += code[j][i-1]
return res
for line in sys.stdin:
print(pocket_pager(line.strip()))
|
# Aizu Problem 00127: Pocket Pager Input
#
import sys, math, os, copy
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
code = {1: "afkpuz", 2: "bglqv.", 3: "chmrw?", 4: "dinsx!", 5: "ejoty "}
def pocket_pager(string):
if len(string) % 2 == 1:
return "NA"
res = ""
for k in range(len(string) // 2):
i = int(string[2*k])
j = int(string[2*k+1])
if not 1 <= i <= 6 or not 1 <= j <= 5:
return "NA"
res += code[j][i-1]
return res
for line in sys.stdin:
print(pocket_pager(line.strip()))
|
[["-", 0, 662, 12, 680, 0, 569, 51, 557, 0, 6], ["+", 0, 662, 12, 680, 0, 569, 51, 557, 0, 6]]
| 5
| 188
| 2
|
dic = {}
base = ord("a")
for x in range(5):
for y in range(5):
dic[(x + 1, y + 1)] = chr(base + x * 5 + y)
dic[(6, 1)] = "z"
dic[(6, 2)] = "."
dic[(6, 3)] = "?"
dic[(6, 4)] = "!"
dic[(6, 5)] = " "
def to_mess(nums):
if len(nums) % 2 == 1:
return "NA"
mess = ""
for i in range(0, len(nums), 2):
x, y = map(int, nums[i: i + 2])
if (x, y) in dic:
mess += dic[(x, y)]
return mess
while True:
try:
nums = input()
print(to_mess(nums))
except EOFError:
break
|
dic = {}
base = ord("a")
for x in range(5):
for y in range(5):
dic[(x + 1, y + 1)] = chr(base + x * 5 + y)
dic[(6, 1)] = "z"
dic[(6, 2)] = "."
dic[(6, 3)] = "?"
dic[(6, 4)] = "!"
dic[(6, 5)] = " "
def to_mess(nums):
if len(nums) % 2 == 1:
return "NA"
mess = ""
for i in range(0, len(nums), 2):
x, y = map(int, nums[i: i + 2])
if (x, y) in dic:
mess += dic[(x, y)]
else:
return "NA"
return mess
while True:
try:
nums = input()
print(to_mess(nums))
except EOFError:
break
|
[["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 0, 57, 75, 76, 8, 196, 0, 37, 0, 38], ["+", 75, 76, 8, 196, 0, 37, 0, 557, 0, 654], ["+", 75, 76, 8, 196, 0, 37, 0, 557, 0, 6], ["+", 75, 76, 8, 196, 0, 37, 0, 557, 0, 655]]
| 5
| 209
| 6
|
decode = ["afkpuz",
"bglqv.",
"chmrw?",
"dinsx!",
"ejoty "]
while True:
try:
line = list(map(int,list(input())))
except EOFError:
break
if len(line)%2 == 1:
print("NA")
continue
try:
print("".join(decode[j-1][i-1]
for i,j in zip(line[::2],line[1::2])))
except IndexError:
print("NA")
|
decode = ["afkpuz",
"bglqv.",
"chmrw?",
"dinsx!",
"ejoty "]
while True:
try:
line = list(map(int,list(input())))
except EOFError:
break
if len(line)%2 == 1 or 0 in line:
print("NA")
continue
try:
print("".join(decode[j-1][i-1]
for i,j in zip(line[::2],line[1::2])))
except IndexError:
print("NA")
|
[["+", 0, 52, 8, 196, 0, 57, 15, 679, 17, 354], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 267], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22]]
| 5
| 118
| 4
|
#include <stdio.h>
int out[6];
int main(void) {
int n, i, j;
float h;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%f", &h);
if (185.0 < h)
out[5]++;
else if (180.0 < h)
out[4]++;
else if (175.0 < h)
out[3]++;
else if (170.0 < h)
out[2]++;
else if (165.0 < h)
out[1]++;
else if (165.0 > h)
out[0]++;
}
for (i = 0; i < 6; i++) {
printf("%d:", i + 1);
for (j = 0; j < out[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
#include <stdio.h>
int out[6];
int main(void) {
int n, i, j;
float h;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%f", &h);
if (185.0 < h)
out[5]++;
else if (180.0 <= h)
out[4]++;
else if (175.0 <= h)
out[3]++;
else if (170.0 <= h)
out[2]++;
else if (165.0 <= h)
out[1]++;
else if (165.0 > h)
out[0]++;
}
for (i = 0; i < 6; i++) {
printf("%d:", i + 1);
for (j = 0; j < out[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
[["-", 75, 76, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 17, 19]]
| 0
| 198
| 8
|
#include <stdio.h>
int main(void) {
int a;
float b;
int c[6] = {0};
int i;
int j;
scanf("%d", &a);
for (i = 0; i < a; i++) {
scanf("%f", &b);
if (b < 165.5) {
c[0]++;
} else if (b < 170.0) {
c[1]++;
} else if (b < 175.0) {
c[2]++;
} else if (b < 180.0) {
c[3]++;
} else if (b < 185.0) {
c[4]++;
} else {
c[5]++;
}
}
for (j = 1; j < 7; j++) {
printf("%d:", j);
for (i = 0; i < c[j - 1]; i++) {
printf("*");
}
printf("\n");
}
return (0);
}
|
#include <stdio.h>
int main(void) {
int n;
float b;
int c[6] = {0};
int i;
int j;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%f", &b);
if (b < 165.0) {
c[0]++;
} else if (b < 170.0) {
c[1]++;
} else if (b < 175.0) {
c[2]++;
} else if (b < 180.0) {
c[3]++;
} else if (b < 185.0) {
c[4]++;
} else {
c[5]++;
}
}
for (j = 1; j < 7; j++) {
printf("%d:", j);
for (i = 0; i < c[j - 1]; i++) {
printf("*");
}
printf("\n");
}
return (0);
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
| 0
| 212
| 8
|
#include <stdio.h>
int main(void) {
int n;
double h;
int hight[6] = {};
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf", &h);
if (h < 165.0) {
hight[0]++;
} else if (h >= 165.0 && h < 170.0) {
hight[1]++;
} else if (h >= 170.0 && h < 175.0) {
hight[2]++;
} else if (h >= 175.0 && h < 180.0) {
hight[3]++;
} else if (h >= 180.0 && h < 185.0) {
hight[4]++;
} else if (h >= 18050) {
hight[5]++;
}
}
for (int i = 0; i < 6; i++) {
printf("%d:", i + 1);
for (int j = 0; j < hight[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int n;
double h;
int hight[6] = {};
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf", &h);
if (h < 165.0) {
hight[0]++;
} else if (h >= 165.0 && h < 170.0) {
hight[1]++;
} else if (h >= 170.0 && h < 175.0) {
hight[2]++;
} else if (h >= 175.0 && h < 180.0) {
hight[3]++;
} else if (h >= 180.0 && h < 185.0) {
hight[4]++;
} else if (h >= 185.0) {
hight[5]++;
}
}
for (int i = 0; i < 6; i++) {
printf("%d:", i + 1);
for (int j = 0; j < hight[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
[["-", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13]]
| 0
| 228
| 2
|
#include <stdio.h>
int hist[6];
int main() {
int i, j, n;
double t;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lf", &t);
if (t < 165.0) {
hist[0]++;
} else if (t >= 185.0) {
hist[5]++;
} else {
hist[(int)((t - 165.0) / 5.0) + 1]++;
}
}
for (i = 0; i < 6; i++) {
printf("%d:", i);
for (j = 0; j < hist[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
#include <stdio.h>
int hist[6];
int main() {
int i, j, n;
double t;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lf", &t);
if (t < 165.0) {
hist[0]++;
} else if (t >= 185.0) {
hist[5]++;
} else {
hist[(int)((t - 165.0) / 5.0) + 1]++;
}
}
for (i = 0; i < 6; i++) {
printf("%d:", i + 1);
for (j = 0; j < hist[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 0
| 169
| 2
|
#include <stdio.h>
int main() {
int i;
int n;
int a[6];
double b;
int j;
for (i = 0; i < 6; i++) {
a[i] = 0;
}
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lf", &b);
if (b < 165.0) {
a[0]++;
} else if (b < 170.0) {
a[1]++;
} else if (b < 175.0) {
a[2]++;
} else if (b < 180.0) {
a[3]++;
} else if (b < 185.0) {
a[4]++;
} else {
a[5]++;
}
}
for (i = 0; i < 6; i++) {
printf("%d", i + 1);
printf(";");
for (j = 0; j < a[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
int i;
int n;
int a[6];
double b;
int j;
for (i = 0; i < 6; i++) {
a[i] = 0;
}
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lf", &b);
if (b < 165.0) {
a[0]++;
} else if (b < 170.0) {
a[1]++;
} else if (b < 175.0) {
a[2]++;
} else if (b < 180.0) {
a[3]++;
} else if (b < 185.0) {
a[4]++;
} else {
a[5]++;
}
}
for (i = 0; i < 6; i++) {
printf("%d", i + 1);
printf(":");
for (j = 0; j < a[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 234
| 2
|
#include <stdio.h>
int main() {
int n, i, j, t[7] = {};
float s;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%f", &s);
if (s < 165.0) {
t[1]++;
} else if (s >= 165.0 && s < 170.0) {
t[2]++;
} else if (s >= 170.0 && s < 175.0) {
t[3]++;
} else if (s >= 175.0 && s < 180.0) {
t[4]++;
} else if (s >= 180.0 && s < 185.0) {
t[5]++;
} else if (s >= 185.0) {
t[6]++;
}
}
for (i = 1; i <= 6; i++) {
printf(":%d", i);
for (j = 1; j <= t[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
int n, i, j, t[7] = {};
float s;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%f", &s);
if (s < 165.0) {
t[1]++;
} else if (s >= 165.0 && s < 170.0) {
t[2]++;
} else if (s >= 170.0 && s < 175.0) {
t[3]++;
} else if (s >= 175.0 && s < 180.0) {
t[4]++;
} else if (s >= 180.0 && s < 185.0) {
t[5]++;
} else if (s >= 185.0) {
t[6]++;
}
}
for (i = 1; i <= 6; i++) {
printf("%d:", i);
for (j = 1; j <= t[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 225
| 2
|
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int n, list[6];
double h;
int main() {
for (scanf("%d", &n); n > 0; n--) {
scanf("%lf", &h);
if (h < 165.0)
list[0]++;
else if (h < 170.0)
list[1]++;
else if (h < 175.0)
list[2]++;
else if (h < 180.0)
list[3]++;
else if (h < 185.0)
list[4]++;
else
list[5]++;
}
for (n = 0; n < 6; n++) {
printf("%d:", n);
for (; list[n] > 0; list[n]--)
printf("*");
printf("\n");
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int n, list[6];
double h;
int main() {
for (scanf("%d", &n); n > 0; n--) {
scanf("%lf", &h);
if (h < 165.0)
list[0]++;
else if (h < 170.0)
list[1]++;
else if (h < 175.0)
list[2]++;
else if (h < 180.0)
list[3]++;
else if (h < 185.0)
list[4]++;
else
list[5]++;
}
for (n = 0; n < 6; n++) {
printf("%d:", n + 1);
for (; list[n] > 0; list[n]--)
printf("*");
printf("\n");
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 0
| 182
| 2
|
#include <stdio.h>
int lank[6], n, i;
int main(void) {
double h;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lf", &h);
if (h < 165.5) {
lank[0]++;
} else if (h < 170) {
lank[1]++;
} else if (h < 175) {
lank[2]++;
} else if (h < 180) {
lank[3]++;
} else if (h < 185) {
lank[4]++;
} else {
lank[5]++;
}
}
for (n = 0; n < 6; n++) {
printf("%d:", n + 1);
for (i = 0; i < lank[n]; i++) {
printf("*");
}
printf("\n");
}
return (0);
}
|
#include <stdio.h>
int lank[6], n, i;
int main(void) {
double h;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lf", &h);
if (h < 165.0) {
lank[0]++;
} else if (h < 170) {
lank[1]++;
} else if (h < 175) {
lank[2]++;
} else if (h < 180) {
lank[3]++;
} else if (h < 185) {
lank[4]++;
} else {
lank[5]++;
}
}
for (n = 0; n < 6; n++) {
printf("%d:", n + 1);
for (i = 0; i < lank[n]; i++) {
printf("*");
}
printf("\n");
}
return (0);
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
| 0
| 203
| 2
|
#include <stdio.h>
int main() {
int n, fd[6] = {}, i, j;
double height;
scanf("%d", &n);
while (n--) {
scanf("%lf", &height);
if (height >= 185.0)
fd[5]++;
else if (height >= 180.0)
fd[4]++;
else if (height >= 175.0)
fd[3]++;
else if (height >= 170.0)
fd[2]++;
else if (height >= 165.5)
fd[1]++;
else
fd[0]++;
}
for (i = 0; i < 6; i++) {
printf("%d:", i + 1);
for (j = 0; j < fd[i]; j++)
putchar('*');
puts("");
}
return 0;
}
|
#include <stdio.h>
int main() {
int n, fd[6] = {}, i, j;
double height;
scanf("%d", &n);
while (n--) {
scanf("%lf", &height);
if (height >= 185.0)
fd[5]++;
else if (height >= 180.0)
fd[4]++;
else if (height >= 175.0)
fd[3]++;
else if (height >= 170.0)
fd[2]++;
else if (height >= 165.0)
fd[1]++;
else
fd[0]++;
}
for (i = 0; i < 6; i++) {
printf("%d:", i + 1);
for (j = 0; j < fd[i]; j++)
putchar('*');
puts("");
}
return 0;
}
|
[["-", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 12, 13]]
| 0
| 182
| 2
|
#include <stdio.h>
int main() {
int n[8] = {}, N, x, y;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d.%d", &x, &y);
if (185 <= x)
n[6]++;
else if (180 <= x)
n[5]++;
else if (175 <= x)
n[4]++;
else if (170 <= x)
n[3]++;
else if (165 <= x)
n[2]++;
else if (165 > x)
n[1]++;
}
for (int i = 1; i <= 7; i++) {
printf("%d:", i);
for (int j = 0; j < n[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
int n[8] = {}, N, x, y;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d.%d", &x, &y);
if (185 <= x)
n[6]++;
else if (180 <= x)
n[5]++;
else if (175 <= x)
n[4]++;
else if (170 <= x)
n[3]++;
else if (165 <= x)
n[2]++;
else if (165 > x)
n[1]++;
}
for (int i = 1; i <= 6; i++) {
printf("%d:", i);
for (int j = 0; j < n[i]; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 200
| 2
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main() {
double h[6] = {165.0, 170.0, 175.0, 180.0, 185.0, 1e9};
int n;
cin >> n;
vector<int> out(6);
while (n--) {
double a;
cin >> a;
rep(i, 6) if (a < h[i]) {
out[i]++;
break;
}
}
rep(i, 6) {
cout << i << ":";
rep(j, out[i]) cout << "*";
cout << endl;
}
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main() {
double h[6] = {165.0, 170.0, 175.0, 180.0, 185.0, 1e9};
int n;
cin >> n;
vector<int> out(6);
while (n--) {
double a;
cin >> a;
rep(i, 6) if (a < h[i]) {
out[i]++;
break;
}
}
rep(i, 6) {
cout << i + 1 << ":";
rep(j, out[i]) cout << "*";
cout << endl;
}
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 201
| 2
|
#include <iostream>
using namespace std;
int n, w[7], b;
double a;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
b = (a - 155.0) / 2;
if (b < 1) {
b = 1;
}
if (b > 6) {
b = 6;
}
w[b]++;
}
for (int i = 1; i <= 6; i++) {
cout << i << ':';
for (int j = 0; j < w[i]; j++) {
cout << '*';
}
cout << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int n, w[7], b;
double a;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
b = (a - 155.0) / 5;
if (b < 1) {
b = 1;
}
if (b > 6) {
b = 6;
}
w[b]++;
}
for (int i = 1; i <= 6; i++) {
cout << i << ':';
for (int j = 0; j < w[i]; j++) {
cout << '*';
}
cout << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
| 1
| 145
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, a, b[6] = {0};
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
if (a < 165)
b[0]++;
if (a >= 165 && a < 170)
b[1]++;
if (a >= 170 && a < 175)
b[2]++;
if (a >= 175 && a < 180)
b[3]++;
if (a >= 180 && a < 185)
b[4]++;
if (a >= 185)
b[5]++;
}
for (int i = 0; i < 6; i++) {
cout << i + 1 << ":";
for (int j = 0; j < b[i]; j++)
cout << "*";
cout << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
double n, a, b[6] = {0};
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
if (a < 165)
b[0]++;
if (a >= 165 && a < 170)
b[1]++;
if (a >= 170 && a < 175)
b[2]++;
if (a >= 175 && a < 180)
b[3]++;
if (a >= 180 && a < 185)
b[4]++;
if (a >= 185)
b[5]++;
}
for (int i = 0; i < 6; i++) {
cout << i + 1 << ":";
for (int j = 0; j < b[i]; j++)
cout << "*";
cout << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
| 1
| 196
| 2
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
double a;
int n;
string ans[6] = {"", "", "", "", "", ""};
int main() {
cin >> n;
REP(i, n) {
cin >> a;
for (int j = 0; j < 6; j++) {
if (a < 165 + 5 * j) {
ans[j] += "*";
break;
}
}
}
REP(j, 6) cout << j << ':' << ans[j] << endl;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second
#define PI acos(-1.0)
#define INF 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
double a;
int n;
string ans[6] = {"", "", "", "", "", ""};
int main() {
cin >> n;
REP(i, n) {
cin >> a;
for (int j = 0; j < 6; j++) {
if (a < 165 + 5 * j) {
ans[j] += "*";
break;
}
}
}
REP(j, 6) cout << j + 1 << ':' << ans[j] << endl;
}
|
[["+", 31, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 223
| 2
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, cnt[6] = {0};
float h;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h;
if (h < 165.0) {
cnt[0]++;
} else if (h < 170.0) {
cnt[1]++;
} else if (h < 175.0) {
cnt[2]++;
} else if (h < 180.0) {
cnt[3]++;
} else if (h < 185.0) {
cnt[4]++;
} else {
cnt[5]++;
}
}
for (int i = 0; i < 6; i++) {
cout << i << ":";
for (int j = 0; j < cnt[i]; j++) {
cout << "*";
}
cout << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
int n, cnt[6] = {0};
float h;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h;
if (h < 165.0) {
cnt[0]++;
} else if (h < 170.0) {
cnt[1]++;
} else if (h < 175.0) {
cnt[2]++;
} else if (h < 180.0) {
cnt[3]++;
} else if (h < 185.0) {
cnt[4]++;
} else {
cnt[5]++;
}
}
for (int i = 0; i < 6; i++) {
cout << i + 1 << ":";
for (int j = 0; j < cnt[i]; j++) {
cout << "*";
}
cout << endl;
}
return 0;
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 194
| 2
|
#include <iostream>
using namespace std;
int main() {
int length[6];
for (int i = 0; i < 6; i++) {
length[i] = 0;
}
int n;
cin >> n;
for (int i = 0; i < n; i++) {
double l;
cin >> l;
if (l < 165.0)
length[0]++;
else if (l < 170.0)
length[1]++;
else if (l < 175.0)
length[2]++;
else if (l < 180.0)
length[3]++;
else if (l < 185.0)
length[4]++;
else
length[5]++;
}
for (int i = 0; i < 6; i++) {
cout << i << ":";
for (int j = 0; j < length[i]; j++) {
cout << "*";
}
cout << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int length[6];
for (int i = 0; i < 6; i++) {
length[i] = 0;
}
int n;
cin >> n;
for (int i = 0; i < n; i++) {
double l;
cin >> l;
if (l < 165.0)
length[0]++;
else if (l < 170.0)
length[1]++;
else if (l < 175.0)
length[2]++;
else if (l < 180.0)
length[3]++;
else if (l < 185.0)
length[4]++;
else
length[5]++;
}
for (int i = 0; i < 6; i++) {
cout << i + 1 << ":";
for (int j = 0; j < length[i]; j++) {
cout << "*";
}
cout << endl;
}
return 0;
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 198
| 2
|
#include <cstdio>
#include <vector>
using namespace std;
int main() {
int n;
while (~scanf("%d", &n)) {
vector<int> g(6, 0);
for (int i = 0; i < n; ++i) {
double h;
scanf("%lf", &h);
if (h < 165.0)
++g[0];
else if (h < 170.0)
++g[1];
else if (h < 175.0)
++g[2];
else if (h < 180.0)
++g[3];
else if (h < 185.0)
++g[4];
else
++g[5];
}
for (int i = 0; i < 6; ++i) {
printf("%d:", i);
for (int j = 0; j < g[i]; ++j)
printf("*");
puts("");
}
}
return 0;
}
|
#include <cstdio>
#include <vector>
using namespace std;
int main() {
int n;
while (~scanf("%d", &n)) {
vector<int> g(6, 0);
for (int i = 0; i < n; ++i) {
double h;
scanf("%lf", &h);
if (h < 165.0)
++g[0];
else if (h < 170.0)
++g[1];
else if (h < 175.0)
++g[2];
else if (h < 180.0)
++g[3];
else if (h < 185.0)
++g[4];
else
++g[5];
}
for (int i = 0; i < 6; ++i) {
printf("%d:", i + 1);
for (int j = 0; j < g[i]; ++j)
printf("*");
puts("");
}
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 201
| 2
|
#include <iostream>
using namespace std;
int p[7];
int main() {
int num;
float height;
for (int i = 0; i < 8; i++)
p[i] = 0;
cin >> num;
for (int i = 0; i < num; i++) {
cin >> height;
if (height < 165.0)
p[1]++;
else if (height < 170.0)
p[2]++;
else if (height < 175.0)
p[3]++;
else if (height < 180.0)
p[4]++;
else if (height < 180.5)
p[5]++;
else
p[6]++;
}
for (int i = 1; i <= 6; i++) {
cout << i << ":";
for (int j = 0; j < p[i]; j++) {
cout << "*";
}
cout << endl;
}
}
|
#include <iostream>
using namespace std;
int p[7];
int main() {
int num;
float height;
for (int i = 0; i < 8; i++)
p[i] = 0;
cin >> num;
for (int i = 0; i < num; i++) {
cin >> height;
if (height < 165.0)
p[1]++;
else if (height < 170.0)
p[2]++;
else if (height < 175.0)
p[3]++;
else if (height < 180.0)
p[4]++;
else if (height < 185.0)
p[5]++;
else
p[6]++;
}
for (int i = 1; i <= 6; i++) {
cout << i << ":";
for (int j = 0; j < p[i]; j++) {
cout << "*";
}
cout << endl;
}
}
|
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 193
| 2
|
#include <iostream>
using namespace std;
int main() {
long n, aa[6] = {0}, i, j;
double a;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a;
if (a < 165)
aa[0]++;
else if (a < 170)
aa[1]++;
else if (a < 175)
aa[2]++;
else if (a < 180)
aa[3]++;
else if (a < 185)
aa[4]++;
else
aa[5]++;
}
for (j = 0; j < 6; j++) {
cout << j << ":";
for (i = 0; i < aa[j]; i++)
cout << "*";
cout << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
long n, aa[6] = {0}, i, j;
double a;
cin >> n;
for (i = 0; i < n; i++) {
cin >> a;
if (a < 165)
aa[0]++;
else if (a < 170)
aa[1]++;
else if (a < 175)
aa[2]++;
else if (a < 180)
aa[3]++;
else if (a < 185)
aa[4]++;
else
aa[5]++;
}
for (j = 0; j < 6; j++) {
cout << j + 1 << ":";
for (i = 0; i < aa[j]; i++)
cout << "*";
cout << endl;
}
return 0;
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 177
| 2
|
#include <iostream>
using namespace std;
int main() {
int n;
int a[1024];
int r[6] = {0};
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] < 165)
r[0]++;
else if (a[i] < 170)
r[1]++;
else if (a[i] < 175)
r[2]++;
else if (a[i] < 180)
r[3]++;
else if (a[i] < 185)
r[4]++;
else
r[5]++;
}
for (int i = 0; i < 6; i++) {
cout << i + 1 << ':';
for (int j = 0; j < r[i]; j++)
cout << '*';
cout << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
int n;
double a[1024];
int r[6] = {0};
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] < 165)
r[0]++;
else if (a[i] < 170)
r[1]++;
else if (a[i] < 175)
r[2]++;
else if (a[i] < 180)
r[3]++;
else if (a[i] < 185)
r[4]++;
else
r[5]++;
}
for (int i = 0; i < 6; i++) {
cout << i + 1 << ':';
for (int j = 0; j < r[i]; j++)
cout << '*';
cout << endl;
}
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
| 1
| 197
| 2
|
n = int(input())
[out1, out2, out3, out4, out5, out6] = [0 for i in range(6)]
for i in range(n):
k = float(input())
if k < 165.0: out1 += 1
elif 165.0 <= k < 170.0: out2 += 1
elif 170.0 <= k < 175.0: out3 += 1
elif 175.0 <= k < 180.0: out4 += 1
elif 180.0 <= k < 185.0: out5 += 1
elif 185.0 >= k: out6 += 1
for j,k in zip([i for i in range(1,7)],[out1, out2, out3, out4, out5, out6]):
print(str(j) + ':' + '*'*k)
|
n = int(input())
[out1, out2, out3, out4, out5, out6] = [0 for i in range(6)]
for i in range(n):
k = float(input())
if k < 165.0: out1 += 1
elif 165.0 <= k < 170.0: out2 += 1
elif 170.0 <= k < 175.0: out3 += 1
elif 175.0 <= k < 180.0: out4 += 1
elif 180.0 <= k < 185.0: out5 += 1
elif 185.0 <= k: out6 += 1
for j,k in zip([i for i in range(1,7)],[out1, out2, out3, out4, out5, out6]):
print(str(j) + ':' + '*'*k)
|
[["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 20], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 667, 19]]
| 5
| 156
| 2
|
histo = ["" for i in range(6)]
n = int(input())
for i in range(n):
h = float(input())
if h < 165.0:
histo[0] += "*"
elif h < 170.0:
histo[1] += "*"
elif h < 175.0:
histo[2] += "*"
elif h < 180.0:
histo[3] += "*"
elif h < 185.0:
histo[4] += "*"
else:
histo[5] += "*"
for i in range(6):
print("%d:%a"%(i,a[i]))
|
histo = ["" for i in range(6)]
n = int(input())
for i in range(n):
h = float(input())
if h < 165.0: histo[0] += "*"
elif h < 170.0: histo[1] += "*"
elif h < 175.0: histo[2] += "*"
elif h < 180.0: histo[3] += "*"
elif h < 185.0: histo[4] += "*"
else : histo[5] += "*"
for i in range(6):
print("%d:%-s"%(i+1,histo[i]))
|
[["-", 0, 652, 3, 4, 0, 657, 31, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 6], ["+", 3, 4, 0, 657, 12, 660, 0, 657, 17, 72], ["+", 3, 4, 0, 657, 12, 660, 0, 657, 12, 612], ["-", 3, 4, 0, 657, 12, 660, 0, 206, 51, 22], ["+", 3, 4, 0, 657, 12, 660, 0, 206, 51, 22]]
| 5
| 135
| 6
|
import java.util.*;
public class Main {
public void doIt() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int count = 0;
for (int i = 0; i < n; i++) {
long num = sc.nextInt();
System.out.println("Case " + count++ + ":");
for (int j = 0; j < 10; j++) {
if (num == 0) {
num = 1;
} else {
num = num * num;
}
num = num / 100;
num = num % 10000;
System.out.println(num);
}
}
}
public static void main(String[] args) {
Main obj = new Main();
obj.doIt();
}
}
|
import java.util.*;
public class Main {
public void doIt() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int count = 1;
for (int i = 0; i < n; i++) {
long num = sc.nextInt();
System.out.println("Case " + count++ + ":");
for (int j = 0; j < 10; j++) {
if (num == 0) {
num = 1;
} else {
num = num * num;
}
num = num / 100;
num = num % 10000;
System.out.println(num);
}
}
}
public static void main(String[] args) {
Main obj = new Main();
obj.doIt();
}
}
|
[["-", 0, 195, 8, 196, 0, 503, 49, 200, 51, 499], ["+", 0, 195, 8, 196, 0, 503, 49, 200, 51, 499]]
| 3
| 171
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; i++) {
int x = s.nextInt();
System.out.println("Case" + (i + 1) + ":");
for (int j = 0; j < 10; j++) {
x *= x;
String str = String.format("%08d", x);
x = Integer.parseInt(str.substring(2, 6));
System.out.println(x);
}
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; i++) {
int x = s.nextInt();
System.out.println("Case " + (i + 1) + ":");
for (int j = 0; j < 10; j++) {
x *= x;
String str = String.format("%08d", x);
x = Integer.parseInt(str.substring(2, 6));
System.out.println(x);
}
}
}
}
|
[["-", 3, 4, 0, 16, 31, 16, 31, 5, 0, 491], ["+", 3, 4, 0, 16, 31, 16, 31, 5, 0, 491]]
| 3
| 149
| 2
|
import java.util.Scanner;
public class Main {
int makeRandom(int value) { return ((value * value) % 1000000) / 100; }
void io() {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; ++i) {
int initial = s.nextInt();
System.out.println("case " + (i + 1) + ":");
for (int j = 0; j < 10; ++j) {
initial = makeRandom(initial);
System.out.println(initial);
}
}
s.close();
}
public static void main(String[] args) { new Main().io(); }
}
|
import java.util.Scanner;
public class Main {
int makeRandom(int value) { return ((value * value) % 1000000) / 100; }
void io() {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i = 0; i < n; ++i) {
int initial = s.nextInt();
System.out.println("Case " + (i + 1) + ":");
for (int j = 0; j < 10; ++j) {
initial = makeRandom(initial);
System.out.println(initial);
}
}
s.close();
}
public static void main(String[] args) { new Main().io(); }
}
|
[["-", 3, 4, 0, 16, 31, 16, 31, 5, 0, 491], ["+", 3, 4, 0, 16, 31, 16, 31, 5, 0, 491]]
| 3
| 164
| 2
|
#include <stdio.h>
int main(void) {
int n;
int s;
int rund;
int i;
int j;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &s);
printf("Case %d:\n", s);
for (j = 0; j < 10; j++) {
s = s * s / 100 % 10000;
printf("%d\n", s);
}
}
return (0);
}
|
#include <stdio.h>
int main(void) {
int n;
int s;
int rund;
int i;
int j;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &s);
printf("Case %d:\n", i);
for (j = 0; j < 10; j++) {
s = s * s / 100 % 10000;
printf("%d\n", s);
}
}
return (0);
}
|
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
| 0
| 109
| 2
|
#include <stdio.h>
int main(void) {
int x;
int s;
int n;
int i;
int j;
scanf("%d", &x);
for (i = 0; i < x; i++) {
scanf("%d", &s);
printf("case %d:\n", i + 1);
for (j = 0; j < 10; j++) {
s *= s;
s /= 100;
s %= 10000;
printf("%d\n", s);
}
}
return (0);
}
|
#include <stdio.h>
int main(void) {
int x;
int s;
int i;
int j;
scanf("%d", &x);
for (i = 0; i < x; i++) {
scanf("%d", &s);
printf("Case %d:\n", i + 1);
for (j = 0; j < 10; j++) {
s *= s;
s /= 100;
s %= 10000;
printf("%d\n", s);
}
}
return (0);
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 113
| 5
|
#include <stdio.h>
int main(void) {
int i, j, repeat, dataset[10];
scanf("%d", &repeat);
for (j = 0; j < repeat; j++) {
scanf("%d", &dataset[j]);
}
for (j = 0; j < repeat; j++) {
printf("Case %d\n", j + 1);
for (i = 0; i < 10; i++) {
dataset[j] = (int)((dataset[j] * dataset[j]) % 1000000) / 100;
printf("%d\n", dataset[j]);
}
}
}
|
#include <stdio.h>
int main(void) {
int i, j, repeat, dataset[10];
scanf("%d", &repeat);
for (j = 0; j < repeat; j++) {
scanf("%d", &dataset[j]);
}
for (j = 0; j < repeat; j++) {
printf("Case %d:\n", j + 1);
for (i = 0; i < 10; i++) {
dataset[j] = (int)((dataset[j] * dataset[j]) % 1000000) / 100;
printf("%d\n", dataset[j]);
}
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 140
| 2
|
#include <stdio.h>
int main(void) {
int n;
int rnd;
int i, j;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &rnd);
printf("case:%d\n", i + 1);
for (j = 0; j < 10; j++) {
rnd = ((rnd * rnd) / 100) % 10000;
printf("%d\n", rnd);
}
}
return (0);
}
|
#include <stdio.h>
int main(void) {
int n;
int rnd;
int i, j;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &rnd);
printf("Case %d:\n", i + 1);
for (j = 0; j < 10; j++) {
rnd = ((rnd * rnd) / 100) % 10000;
printf("%d\n", rnd);
}
}
return (0);
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 111
| 2
|
#include <algorithm>
#include <limits>
#include <stdio.h>
#include <utility>
using namespace std;
int main() {
const int N1 = 3, N2 = 8;
int i, j;
pair<double, int> a[N2], w1, w2;
w1.first = w2.first = numeric_limits<double>::max();
for (i = 0; i < N1; ++i) {
for (j = 0; j < N2; ++j) {
scanf("%d %lf", &a[j].second, &a[j].first);
}
sort(a, a + N2);
for (j = 0; j < 2; ++j)
printf("%d %.2f\n", a[j].second, a[j].first);
for (j = 2; j < 4; ++j) {
if (w1.first > a[j].first) {
w2 = w1;
w1 = a[j];
}
if (w2.first > a[j].first)
w2 = a[j];
}
}
printf("%d %.2f\n"
"%d %.2f\n",
w1.second, w1.first, w2.second, w2.first);
return 0;
}
|
#include <algorithm>
#include <limits>
#include <stdio.h>
#include <utility>
using namespace std;
int main() {
const int N1 = 3, N2 = 8;
int i, j;
pair<double, int> a[N2], w1, w2;
w1.first = w2.first = numeric_limits<double>::max();
for (i = 0; i < N1; ++i) {
for (j = 0; j < N2; ++j) {
scanf("%d %lf", &a[j].second, &a[j].first);
}
sort(a, a + N2);
for (j = 0; j < 2; ++j)
printf("%d %.2f\n", a[j].second, a[j].first);
for (j = 2; j < 4; ++j) {
if (w1.first > a[j].first) {
w2 = w1;
w1 = a[j];
} else if (w2.first > a[j].first)
w2 = a[j];
}
}
printf("%d %.2f\n"
"%d %.2f\n",
w1.second, w1.first, w2.second, w2.first);
return 0;
}
|
[["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
| 1
| 254
| 1
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
using namespace std;
vector<pair<int, float>> other;
bool pairCompare(const std::pair<int, int> &firstElem,
const std::pair<int, int> &secondElem) {
return firstElem.second > secondElem.second;
}
int main() {
for (int j = 0; j < 3; j++) {
vector<pair<int, float>> timer;
for (int i = 0; i < 8; i++) {
int n;
float t;
cin >> n >> t;
timer.push_back(mp(n, t));
}
sort(timer.begin(), timer.end(), pairCompare);
printf("%d %.2f\n", timer[timer.size() - 1].first,
timer[timer.size() - 1].second);
printf("%d %.2f\n", timer[timer.size() - 2].first,
timer[timer.size() - 2].second);
timer.pop_back();
timer.pop_back();
for (int i = 0; i < timer.size(); i++) {
other.push_back(timer[i]);
}
timer.clear();
}
sort(other.begin(), other.end(), pairCompare);
printf("%d %.2f\n", other[other.size() - 1].first,
other[other.size() - 1].second);
printf("%d %.2f\n", other[other.size() - 2].first,
other[other.size() - 2].second);
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
using namespace std;
vector<pair<int, float>> other;
bool pairCompare(const std::pair<int, double> &firstElem,
const std::pair<int, double> &secondElem) {
return firstElem.second > secondElem.second;
}
int main() {
for (int j = 0; j < 3; j++) {
vector<pair<int, double>> timer;
for (int i = 0; i < 8; i++) {
int n;
double t;
cin >> n >> t;
timer.push_back(mp(n, t));
}
sort(timer.begin(), timer.end(), pairCompare);
printf("%d %.2f\n", timer[timer.size() - 1].first,
timer[timer.size() - 1].second);
printf("%d %.2f\n", timer[timer.size() - 2].first,
timer[timer.size() - 2].second);
timer.pop_back();
timer.pop_back();
for (int i = 0; i < timer.size(); i++) {
other.push_back(timer[i]);
}
timer.clear();
}
sort(other.begin(), other.end(), pairCompare);
printf("%d %.2f\n", other[other.size() - 1].first,
other[other.size() - 1].second);
printf("%d %.2f\n", other[other.size() - 2].first,
other[other.size() - 2].second);
}
|
[["-", 39, 343, 141, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 343, 141, 344, 3, 347, 0, 77, 39, 40], ["-", 0, 77, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 77, 39, 344, 3, 347, 0, 77, 39, 40], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40]]
| 1
| 409
| 8
|
r=[*$<];p r;a,b,c=r[0,8].sort_by{|t|t.split[1].to_f},r[8,8].sort_by{|t|t.split[1].to_f},r[16,8].sort_by{|t|t.split[1].to_f};puts a[0,2],b[0,2],c[0,2];*u=*a[2,6],*b[2,6],*c[2,6];
puts u.sort_by{|t|t.split[1].to_f}[0,2]
|
r=[*$<];a,b,c=r[0,8].sort_by{|t|t.split[1].to_f},r[8,8].sort_by{|t|t.split[1].to_f},r[16,8].sort_by{|t|t.split[1].to_f};puts a[0,2],b[0,2],c[0,2];*u=*a[2,6],*b[2,6],*c[2,6];
puts u.sort_by{|t|t.split[1].to_f}[0,2]
|
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22], ["-", 36, 36, 36, 36, 36, 36, 0, 493, 0, 35]]
| 4
| 153
| 3
|
import sys
R = lambda:list(map(int,input().split()))
t2 = [[] for i in range(3)]
for i in range(3):
t = []
for j in range(8):
num,time = input().split()
t.append((float(time),int(num)))
t.sort()
for j in range(4):
t2[i].append(t[j])
t3 = []
for i in range(3):
t3.append(t2[i][2])
t3.append(t2[i][3])
t3.sort()
print(t3)
for i in range(3):
print("%d %.2f" % (t2[i][0][1], t2[i][0][0]))
print("%d %.2f" % (t2[i][1][1], t2[i][1][0]))
print("%d %.2f" % (t3[0][1], t3[0][0]))
print("%d %.2f" % (t3[1][1], t3[1][0]))
|
import sys
R = lambda:list(map(int,input().split()))
t2 = [[] for i in range(3)]
for i in range(3):
t = []
for j in range(8):
num,time = input().split()
t.append((float(time),int(num)))
t.sort()
for j in range(4):
t2[i].append(t[j])
t3 = []
for i in range(3):
t3.append(t2[i][2])
t3.append(t2[i][3])
t3.sort()
for i in range(3):
print("%d %.2f" % (t2[i][0][1], t2[i][0][0]))
print("%d %.2f" % (t2[i][1][1], t2[i][1][0]))
print("%d %.2f" % (t3[0][1], t3[0][0]))
print("%d %.2f" % (t3[1][1], t3[1][0]))
|
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
| 5
| 267
| 4
|
#include <stdio.h>
int main() {
int n, i, j;
char s[100001];
scanf("%d", &n);
while (n--) {
scanf("%s", s);
if (s[0] != '>') {
printf("NA");
continue;
}
if (s[1] == '\'') {
for (i = 2; s[i] == '='; i++)
; // printf("%c\n",s[i]);
for (j = 1; s[i - j] == '=' && s[i + j] == '='; j++)
;
if (i - j == 1 && s[i + j] == '~' && s[i + j + 1] == 0 && s[i] == '#' &&
i - 2)
printf("A\n");
else
printf("NA\n");
} else if (s[1] == '^') {
for (i = 2; s[i] == 'Q' && s[i + 1] == '='; i += 2)
;
if (s[i] == '~' && s[i + 1] == '~' && s[i + 2] == 0 && i - 2)
printf("B\n");
else
printf("NA\n");
} else
printf("NA\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
int n, i, j;
char s[100001];
scanf("%d", &n);
while (n--) {
scanf("%s", s);
if (s[0] != '>') {
printf("NA\n");
continue;
}
if (s[1] == '\'') {
for (i = 2; s[i] == '='; i++)
; // printf("%c\n",s[i]);
for (j = 1; s[i - j] == '=' && s[i + j] == '='; j++)
;
if (i - j == 1 && s[i + j] == '~' && s[i + j + 1] == 0 && s[i] == '#' &&
i - 2)
printf("A\n");
else
printf("NA\n");
} else if (s[1] == '^') {
for (i = 2; s[i] == 'Q' && s[i + 1] == '='; i += 2)
;
if (s[i] == '~' && s[i + 1] == '~' && s[i + 2] == 0 && i - 2)
printf("B\n");
else
printf("NA\n");
} else
printf("NA\n");
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 303
| 1
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define rep(i, n) for ((i) = 0; (i) < (n); ++(i))
string solve(string s) {
int i = 0, j;
string tmp;
rep(i, 100) {
tmp += "=";
if (s == ">'" + tmp + "#" + tmp + "~~")
return "A";
}
tmp.clear();
rep(i, 100) {
tmp += "Q=";
if (s == ">^" + tmp + "~~")
return "B";
}
return "NA";
}
int main(void) {
int i, j, n;
string s;
scanf("%d", &n);
for (; n--;) {
cin >> s;
cout << solve(s) << endl;
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define rep(i, n) for ((i) = 0; (i) < (n); ++(i))
string solve(string s) {
int i = 0, j;
string tmp;
rep(i, 100) {
tmp += "=";
if (s == ">'" + tmp + "#" + tmp + "~")
return "A";
}
tmp.clear();
rep(i, 100) {
tmp += "Q=";
if (s == ">^" + tmp + "~~")
return "B";
}
return "NA";
}
int main(void) {
int i, j, n;
string s;
scanf("%d", &n);
for (; n--;) {
cin >> s;
cout << solve(s) << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 16, 12, 5, 0, 6], ["+", 15, 339, 51, 16, 12, 16, 12, 5, 0, 6]]
| 1
| 173
| 2
|
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int n;
string s;
int main() {
cin >> n;
while (cin >> s) {
if (s.size() < 6 || s[0] != '>') {
cout << "NA" << endl;
break;
}
int cur = 2, l = 0, l2 = 0, f = 0, f2 = 0;
if (s[1] == '\'') {
while (cur < s.size()) {
if (f2) {
f2 = 0;
break;
} else if (s[cur] == '=') {
if (!f)
l++;
else
l2++;
} else if (s[cur] == '#') {
if (!l || f)
break;
else
f = 1;
} else if (s[cur] == '~') {
if (l && l == l2) {
f2 = 1;
} else
break;
} else
break;
cur++;
}
} else if (s[1] == '^') {
while (cur < s.size()) {
if (f2) {
f2 = 0;
break;
}
if (s[cur] == 'Q') {
if (!f)
f = 1;
else
break;
} else if (s[cur] == '=') {
if (f == 1)
f = 0;
else
break;
} else if (s[cur] == '~') {
if (!f)
f = 2;
else if (f == 2)
f2 = 2;
else
break;
} else
break;
cur++;
}
}
if (f2 == 1)
cout << "A" << endl;
else if (f2 == 2)
cout << "B" << endl;
else
cout << "NA" << endl;
}
}
|
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int n;
string s;
int main() {
cin >> n;
while (cin >> s) {
if (s.size() < 6 || s[0] != '>') {
cout << "NA" << endl;
continue;
}
int cur = 2, l = 0, l2 = 0, f = 0, f2 = 0;
if (s[1] == '\'') {
while (cur < s.size()) {
if (f2) {
f2 = 0;
break;
} else if (s[cur] == '=') {
if (!f)
l++;
else
l2++;
} else if (s[cur] == '#') {
if (!l || f)
break;
else
f = 1;
} else if (s[cur] == '~') {
if (l && l == l2) {
f2 = 1;
} else
break;
} else
break;
cur++;
}
} else if (s[1] == '^') {
while (cur < s.size()) {
if (f2) {
f2 = 0;
break;
}
if (s[cur] == 'Q') {
if (!f)
f = 1;
else
break;
} else if (s[cur] == '=') {
if (f == 1)
f = 0;
else
break;
} else if (s[cur] == '~') {
if (!f)
f = 2;
else if (f == 2)
f2 = 2;
else
break;
} else
break;
cur++;
}
}
if (f2 == 1)
cout << "A" << endl;
else if (f2 == 2)
cout << "B" << endl;
else
cout << "NA" << endl;
}
}
|
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117]]
| 1
| 405
| 2
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
static const double eps = 10e-9;
bool isA(string str) {
if (str.size() >= 1 && str[0] != '>')
return false;
if (str.size() >= 2 && str[1] != '\'')
return false;
int hist[] = {0, 0};
for (int i = 2, j = 0; i < str.size() - 1; i++) {
if (str[i] == '=') {
hist[j]++;
} else if (str[i] == '#')
j++;
}
if (hist[0] != hist[1])
return false;
if (hist[0] == 0 || hist[1] == 0)
return false;
if (str[str.size() - 1] != '~')
return false;
return true;
}
bool isB(string str) {
if (str.size() >= 1 && str[0] != '>')
return false;
if (str.size() >= 2 && str[1] != '^')
return false;
if (str.size() <= 3)
return false;
string rear = str.substr(2, str.size() - 2);
bool isok = false;
int i;
for (i = 0; i + 1 < rear.size();) {
if (rear.substr(i, 2) == "Q=") {
isok = true;
i += 2;
} else
break;
}
return (i + 2 == rear.size() && isok && rear.substr(i, 2) == "~~");
}
int main() {
int n;
while (~scanf("%d", &n)) {
for (int i = 0; i < n; i++) {
string str;
cin >> str;
if (isA(str))
cout << "A" << endl;
else if (isB(str))
cout << "B" << endl;
else
cout << "NA" << endl;
}
}
}
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
static const double eps = 10e-9;
bool isA(string str) {
if (str.size() >= 1 && str[0] != '>')
return false;
if (str.size() >= 2 && str[1] != '\'')
return false;
int hist[] = {0, 0};
for (int i = 2, j = 0; i < str.size() - 1; i++) {
if (str[i] == '=') {
hist[j]++;
} else if (str[i] == '#')
j++;
else
return false;
}
if (hist[0] != hist[1])
return false;
if (hist[0] == 0 || hist[1] == 0)
return false;
if (str[str.size() - 1] != '~')
return false;
return true;
}
bool isB(string str) {
if (str.size() >= 1 && str[0] != '>')
return false;
if (str.size() >= 2 && str[1] != '^')
return false;
if (str.size() <= 3)
return false;
string rear = str.substr(2, str.size() - 2);
bool isok = false;
int i;
for (i = 0; i + 1 < rear.size();) {
if (rear.substr(i, 2) == "Q=") {
isok = true;
i += 2;
} else
break;
}
return (i + 2 == rear.size() && isok && rear.substr(i, 2) == "~~");
}
int main() {
int n;
while (~scanf("%d", &n)) {
for (int i = 0; i < n; i++) {
string str;
cin >> str;
if (isA(str))
cout << "A" << endl;
else if (isB(str))
cout << "B" << endl;
else
cout << "NA" << endl;
}
}
}
|
[["+", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95], ["+", 75, 76, 0, 57, 75, 76, 0, 37, 0, 38], ["+", 75, 76, 0, 57, 75, 76, 0, 37, 0, 147], ["+", 75, 76, 0, 57, 75, 76, 0, 37, 0, 35]]
| 1
| 484
| 4
|
gets.to_i.times do
s = gets.chomp
if s =~ /^>'(=+)#\1~$/
puts ?A
elsif s =~ /^>^(Q=)+(?:.*)~$/
puts ?B
else
puts 'NA'
end
end
|
gets.to_i.times do
s = gets.chomp
if s =~ /^>'(=+)#\1~$/
puts ?A
elsif s =~ /^>\^(Q=)+~~$/
puts ?B
else
puts 'NA'
end
end
|
[["-", 0, 121, 75, 759, 15, 738, 12, 575, 0, 6], ["+", 0, 121, 75, 759, 15, 738, 12, 575, 0, 6], ["+", 0, 121, 75, 759, 15, 738, 12, 575, 0, 44]]
| 4
| 36
| 4
|
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
for (int i = 0; i < n; i++) {
byte s = Byte.parseByte(scan.next());
byte g = Byte.parseByte(scan.next());
if (s < g || s <= 5)
out.println(range(s, g));
else {
if (g >= 6)
out.print(range(s, 9) + " " + range(5, 0) + " " + range(1, g));
else
out.print(range(s, 9) + " " + range(5, g));
}
}
out.flush();
}
static String range(int p, int q) {
int d = p < q ? 1 : -1;
String mes = "";
for (int i = p; i != q; i += d) {
mes += i + " ";
}
return mes + q;
}
}
|
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
for (int i = 0; i < n; i++) {
byte s = Byte.parseByte(scan.next());
byte g = Byte.parseByte(scan.next());
if (s < g || s <= 5)
out.println(range(s, g));
else {
if (g >= 6)
out.println(range(s, 9) + " " + range(5, 0) + " " + range(1, g));
else
out.println(range(s, 9) + " " + range(5, g));
}
}
out.flush();
}
static String range(int p, int q) {
int d = p < q ? 1 : -1;
String mes = "";
for (int i = p; i != q; i += d) {
mes += i + " ";
}
return mes + q;
}
}
|
[["-", 75, 196, 0, 57, 64, 1, 0, 492, 141, 22], ["+", 75, 196, 0, 57, 64, 1, 0, 492, 141, 22], ["-", 75, 196, 0, 57, 75, 1, 0, 492, 141, 22], ["+", 75, 196, 0, 57, 75, 1, 0, 492, 141, 22]]
| 3
| 261
| 4
|
#include <math.h>
#include <stdio.h>
int main() {
int i, ban, n, s, kei;
scanf("%d", &n);
for (ban = 1; ban <= n; ban++) {
scanf("%d", &s);
printf("case %d:\n", ban);
for (i = 1; i <= 10; i++) {
s = s * s;
s = s / 100;
if (s > 10000) {
s = s % 10000;
}
printf("%d\n", s);
}
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main() {
int i, ban, n, s, kei;
scanf("%d", &n);
for (ban = 1; ban <= n; ban++) {
scanf("%d", &s);
printf("Case %d:\n", ban);
for (i = 1; i <= 10; i++) {
s = s * s;
s = s / 100;
if (s > 10000) {
s = s % 10000;
}
printf("%d\n", s);
}
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 120
| 2
|
#include <stdio.h>
int main(void) {
int num, val, n, i;
scanf("%d", &num);
for (n = 0; n < num; n++) {
printf("Case %d:\n", num);
scanf("%d", &val);
for (i = 0; i < 10; i++) {
val = val * val % 100000000;
val = val / 100 % 10000;
printf("%d\n", val);
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int num, val, n, i;
scanf("%d", &num);
for (n = 1; n <= num; ++n) {
printf("Case %d:\n", n);
scanf("%d", &val);
for (i = 0; i < 10; i++) {
val = val * val % 100000000;
val = val / 100 % 10000;
printf("%d\n", val);
}
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
| 0
| 107
| 8
|
#include <stdio.h>
int main(void) {
int n, i, j, random;
scanf("%d", &n);
for (i = 1; i < n; i++) {
scanf("%d", &random);
printf("Case %d:\n", i);
for (j = 0; j < 10; j++) {
random = random * random / 100 % 10000;
printf("%d\n", random);
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int n, i, j, random;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &random);
printf("Case %d:\n", i);
for (j = 0; j < 10; j++) {
random = random * random / 100 % 10000;
printf("%d\n", random);
}
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
| 0
| 101
| 2
|
#include <stdio.h>
int main(void) {
int n, i, j;
int seed;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &seed);
printf("Case %d:\n", i);
for (j = 0; j < 10; j++) {
seed *= seed;
seed = (seed / 100) % 10000;
printf("%d\n", seed);
}
}
return (0);
}
|
#include <stdio.h>
int main(void) {
int n, i, j;
int seed;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &seed);
printf("Case %d:\n", i + 1);
for (j = 0; j < 10; j++) {
seed *= seed;
seed = (seed / 100) % 10000;
printf("%d\n", seed);
}
}
return (0);
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 0
| 108
| 2
|
#include <stdio.h>
int main() {
int N, x, c = 0, x1 = 0;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d", &x);
int ii = i + 1;
printf("Case %d:", ii);
for (int j = 0; j < 10; j++) {
x = x * x;
x1 = x;
c = 1;
while ((x1 / 10) > 0) {
x1 = x1 / 10;
c++;
// printf("%d",x1);
}
if (c <= 2)
x = 0;
else if (c == 3)
x = x / 100;
else if (c == 4)
x = x / 100;
else if (c == 5)
x = x / 100;
else if (c == 6)
x = x / 100;
else if (c == 7) {
x = x % 1000000;
x = x / 100;
} else if (c == 8) {
x = x % 1000000;
x = x / 100;
}
printf("%d\n", x);
}
}
return 0;
}
|
#include <stdio.h>
int main() {
int N, x, c = 0, x1 = 0;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d", &x);
int ii = i + 1;
printf("Case %d:\n", ii);
for (int j = 0; j < 10; j++) {
x = x * x;
x1 = x;
c = 1;
while ((x1 / 10) > 0) {
x1 = x1 / 10;
c++;
// printf("%d",x1);
}
if (c <= 2)
x = 0;
else if (c == 3)
x = x / 100;
else if (c == 4)
x = x / 100;
else if (c == 5)
x = x / 100;
else if (c == 6)
x = x / 100;
else if (c == 7) {
x = x % 1000000;
x = x / 100;
} else if (c == 8) {
x = x % 1000000;
x = x / 100;
}
printf("%d\n", x);
}
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 242
| 1
|
#include <iostream>
using namespace std;
int main() {
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b;
cin >> b;
cout << "Case " << i + 1 << endl;
for (int j = 0; j < 10; j++) {
int a[8] = {};
b *= b;
for (int k = 7; k >= 0; k--) {
a[k] = b % 10;
b /= 10;
}
int t = 1;
b = 0;
for (int k = 5; k >= 2; k--) {
b += a[k] * t;
t *= 10;
}
cout << b << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int b;
cin >> b;
cout << "Case " << i + 1 << ":" << endl;
for (int j = 0; j < 10; j++) {
int a[8] = {};
b *= b;
for (int k = 7; k >= 0; k--) {
a[k] = b % 10;
b /= 10;
}
int t = 1;
b = 0;
for (int k = 5; k >= 2; k--) {
b += a[k] * t;
t *= 10;
}
cout << b << endl;
}
}
return 0;
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151]]
| 1
| 159
| 4
|
#include <iostream>
using namespace std;
int jyo(int);
int main() {
int s, t, u;
cin >> s;
for (int i = 1; i <= s; i++) {
cin >> u;
cout << "Case" << i << ":" << endl;
for (int j = 0; j < 10; j++) {
t = jyo(u);
cout << t / 100 << endl;
u = t / 100;
}
}
return 0;
}
int jyo(int n) {
n *= n;
n -= (n / 10000000) * 10000000;
n -= (n / 1000000) * 1000000;
return n;
}
|
#include <iostream>
using namespace std;
int jyo(int);
int main() {
int s, t, u;
cin >> s;
for (int i = 1; i <= s; i++) {
cin >> u;
cout << "Case " << i << ":" << endl;
for (int j = 0; j < 10; j++) {
t = jyo(u);
cout << t / 100 << endl;
u = t / 100;
}
}
return 0;
}
int jyo(int n) {
n *= n;
n -= (n / 10000000) * 10000000;
n -= (n / 1000000) * 1000000;
return n;
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 138
| 2
|
#include <iostream>
#include <queue>
using namespace std;
int main() {
int n;
int s;
int x = 1;
queue<int> qu;
cin >> n;
while (n--) {
cout << "case" << x++ << ":" << endl;
cin >> s;
for (int i = 0; i < 10; i++) {
s = s * s;
int t = 10000000;
for (int cnt = 0; cnt < 8; cnt++) {
qu.push(s / t);
s %= t;
t /= 10;
}
s = 0;
t = 1000;
for (int cnt = 0; cnt < 8; cnt++) {
if (cnt >= 2 && cnt <= 5) {
s += qu.front() * t;
t /= 10;
}
qu.pop();
}
cout << s << endl;
}
}
return (0);
}
|
#include <iostream>
#include <queue>
using namespace std;
int main() {
int n;
int s;
int x = 1;
queue<int> qu;
cin >> n;
while (n--) {
cout << "Case " << x++ << ":" << endl;
cin >> s;
for (int i = 0; i < 10; i++) {
s = s * s;
int t = 10000000;
for (int cnt = 0; cnt < 8; cnt++) {
qu.push(s / t);
s %= t;
t /= 10;
}
s = 0;
t = 1000;
for (int cnt = 0; cnt < 8; cnt++) {
if (cnt >= 2 && cnt <= 5) {
s += qu.front() * t;
t /= 10;
}
qu.pop();
}
cout << s << endl;
}
}
return (0);
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 188
| 2
|
#include <bits/stdc++.h>
using namespace std;
void serch(int n, int now) {
n *= n;
int random = (n % 1000000 / 100);
cout << random << endl;
if (now < 10)
serch(random, now + 1);
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int num;
cin >> num;
cout << "Case" << i << ':' << endl;
serch(num, 1);
}
}
|
#include <bits/stdc++.h>
using namespace std;
void serch(int n, int now) {
n *= n;
int random = (n % 1000000 / 100);
cout << random << endl;
if (now < 10)
serch(random, now + 1);
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int num;
cin >> num;
cout << "Case " << i << ':' << endl;
serch(num, 1);
}
}
|
[["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 110
| 17
|
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define dump(o) \
{ cerr << #o << " " << o << endl; }
#define dumpc(o) \
{ \
cerr << #o; \
for (auto &e : (o)) \
cerr << " " << e; \
cerr << endl; \
}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;
signed main() {
int d;
cin >> d;
rep(i, 0, d) {
cout << "Case " << i << ":" << endl;
int s;
cin >> s;
rep(j, 0, 10) {
s *= s;
s %= 1000000;
s /= 100;
cout << s << endl;
}
}
return 0;
}
|
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()
#define dump(o) \
{ cerr << #o << " " << o << endl; }
#define dumpc(o) \
{ \
cerr << #o; \
for (auto &e : (o)) \
cerr << " " << e; \
cerr << endl; \
}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;
signed main() {
int d;
cin >> d;
rep(i, 0, d) {
cout << "Case " << i + 1 << ":" << endl;
int s;
cin >> s;
rep(j, 0, 10) {
s *= s;
s %= 1000000;
s /= 100;
cout << s << endl;
}
}
return 0;
}
|
[["+", 0, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 203
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
for (int z = 0; z < a; z++) {
long long n;
cin >> n;
cout << "Case " << z + 1 << endl;
for (int j = 0; j < 10; j++) {
n = n * n;
string a = to_string(n);
int b = a.length();
b = 8 - b;
string t;
for (int i = 0; i < b; i++)
t += "0";
t += a;
string c = t.substr(2, 4);
n = stoi(c);
cout << n << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
for (int z = 0; z < a; z++) {
long long n;
cin >> n;
cout << "Case " << z + 1 << ":" << endl;
for (int j = 0; j < 10; j++) {
n = n * n;
string a = to_string(n);
int b = a.length();
b = 8 - b;
string t;
for (int i = 0; i < b; i++)
t += "0";
t += a;
string c = t.substr(2, 4);
n = stoi(c);
cout << n << endl;
}
}
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151]]
| 1
| 152
| 4
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
int main() {
int n;
cin >> n;
for (int c = 0; c < n; c++) {
string in;
cin >> in;
cout << "Case " << c << " " << endl;
rep(i, 10) {
int num = pow(stoi(in), 2);
in = to_string(num);
string t;
int cnt = in.size();
while (cnt++ < 8)
t.push_back('0');
t += in;
string ans;
for (int i = 2; i <= 6; i++) {
ans.push_back(t[i]);
}
cout << stoi(ans) << endl;
in = ans;
}
}
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
int main() {
int n;
cin >> n;
for (int c = 0; c < n; c++) {
string in;
cin >> in;
cout << "Case " << c + 1 << ":" << endl;
rep(i, 10) {
int num = pow(stoi(in), 2);
in = to_string(num);
string t;
int cnt = in.size();
while (cnt++ < 8)
t.push_back('0');
t += in;
string ans;
for (int i = 2; i <= 5; i++) {
ans.push_back(t[i]);
}
cout << stoi(ans) << endl;
in = ans;
}
}
}
|
[["+", 0, 16, 31, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 16, 31, 16, 31, 16, 12, 16, 12, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 9, 0, 7, 15, 16, 12, 13], ["+", 8, 9, 0, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 268
| 6
|
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on
void solve() {
int n;
cin >> n;
rep(i, n) {
cout << "Case " << i + 1 << endl;
int x;
cin >> x;
rep(j, 10) {
stringstream ss;
ss << setfill('0') << setw(8) << x * x;
string s;
ss >> s;
ss.clear();
ss << s.substr(2, 4);
ss >> x;
cout << x << endl;
}
}
}
|
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on
void solve() {
int n;
cin >> n;
rep(i, n) {
cout << "Case " << i + 1 << ':' << endl;
int x;
cin >> x;
rep(j, 10) {
stringstream ss;
ss << setfill('0') << setw(8) << x * x;
string s;
ss >> s;
ss.clear();
ss << s.substr(2, 4);
ss >> x;
cout << x << endl;
}
}
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 103, 0, 104], ["+", 0, 1, 0, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151]]
| 1
| 431
| 4
|
#include <iostream>
using namespace std;
int main() {
int d;
cin >> d;
for (int i = 1; i <= d; i++) {
int n;
cin >> n;
cout << "Case " << i << endl;
for (int j = 0; j < 10; j++) {
n *= n;
n /= 100;
n %= 10000;
cout << n << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d;
cin >> d;
for (int i = 1; i <= d; i++) {
int n;
cin >> n;
cout << "Case " << i << ":" << endl;
for (int j = 0; j < 10; j++) {
n *= n;
n /= 100;
n %= 10000;
cout << n << endl;
}
}
return 0;
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151]]
| 1
| 89
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.