text
stringlengths 49
983k
|
|---|
#include<iostream>
#include<string>
using namespace std;
int main(){
int n,size;
string s,a,b;
for(cin>>n,getline(cin,s,'\n');n>0;n--){
getline(cin,s,'\n');
//cin>>s;
size = s.size();
if(size<6||size%2){cout<<"NA"<<endl;continue;}
a=">'"; b=">^";
for(int i=0;i<size/2-2;i++){a=a+"=";b=b+"Q=";}
a+="#";
for(int i=0;i<size/2-2;i++){a=a+"=";}
a+="~"; b+="~~";
if (s==a)cout<<"A"<<endl;
else if (s==b)cout<<"B"<<endl;
else cout<<"NA"<<endl;
}
return 0;
}
|
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<regex>
#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 n; cin >> n;
regex b(R"(>\^(Q=)+~~)");
rep(i, 0, n) {
string s; cin >> s;
int m = 0;
rep(j, 0, s.size())if (s[j] == '=')m++;
regex a(">'={" + to_string(m / 2) + "}#={" + to_string(m / 2) + "}~");
if (regex_match(s, a) && m) { cout << "A" << endl; }
else if (regex_match(s, b)) { cout << "B" << endl; }
else cout << "NA" << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
string vbString(int Number,string Character){
string res="";
for(int i=0;i<Number;i++) res+=Character;
return res;
}
string checksnake(string s){
string t;
for(int i=1;i<100;i++){
t=">'"+vbString(i,"=")+"#"+vbString(i,"=")+"~";
if(t==s) return "A";
}
for(int i=1;i<100;i++){
t=">^"+vbString(i,"Q=")+"~~";
if(t==s) return "B";
}
return "NA";
}
int main(){
int n;
cin >> n;
while(n--){
string s;
cin >> s;
cout << checksnake(s) << endl;
}
}
|
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int n;
string s;
int main(void){
cin >> n;
for(int k = 0; k < n; k++){
cin >> s;
bool f = true;
if(s[0]== '>' && s[1]=='\''){
int c=0;
int i;
for(i = 2; s[i]=='='; i++) c++;
if(c && s[i]=='#'){
for(i += 1; s[i]=='='; i++) c--;
if(!c && (int)s.size() == i+1 && s[i]=='~'){
cout << 'A' << endl;
f = false;
}
}
}
else if(s[0]== '>' && s[1]=='^' && s[2]=='Q' && s[3]=='='){
int i;
for(i = 4; s[i]=='Q' && s[i+1]=='='; i+=2);
if((int)s.size() == i+2 && s[i]=='~' && s[i+1]=='~'){
cout << 'B' << endl;
f = false;
}
}
if(f){
cout << "NA" << endl;
}
}
}
|
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>
typedef long long ll;
const double Eps = 1e-6;
using namespace std;
int main()
{
char buf[256];
int n;
scanf("%d\n", &n);
while (n--)
{
cin.getline(buf, sizeof(buf));
string s(buf);
bool ok = false;
for (int i = 1; i < 100; ++i)
{
string a = ">'";
for (int j = 0; j < i; ++j)
a += "=";
a += "#";
for (int j = 0; j < i; ++j)
a += "=";
a += "~";
if (s == a)
{
puts("A");
ok = true;
break;
}
string b = ">^";
for (int j = 0; j < i; ++j)
b += "Q=";
b += "~~";
if (s == b)
{
puts("B");
ok = true;
break;
}
}
if (!ok)
puts("NA");
}
return 0;
}
|
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
int N;
cin>>N;
while(N--){
string str;
cin>>str;
int len=str.size();
int ans=-1;
if(str[0]=='>'&&str[1]=='\''){
int pos=2;
int cnt=0;
int turn=0;
int flag=0;
do{
if(str[pos]=='=')
cnt+=(turn)?(-1):(1);
else if(str[pos]=='#')turn=1;
else flag=0;
if(pos==2&&cnt>0)flag=1;
pos++;
}while(pos<len-1);
if(cnt==0&&flag&&str[pos]=='~')ans=0;
}
else if(str[0]=='>'&&str[1]=='^'){
int pos=2;
int flag=1;
do{
if(str[pos]!='Q'||str[pos+1]!='='){
flag=0;
break;
}
pos+=2;
}while(pos<len-2);
if(flag&&str[pos]=='~'&&str[pos+1]=='~')ans=1;
}
if(ans==0)cout<<"A"<<endl;
else if(ans==1)cout<<"B"<<endl;
else cout<<"NA"<<endl;
}
return 0;
}
|
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>
#define M_PI 3.14159265358979323846
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
int to, cost, nm;
Edge(int to, int cost, int nm): to(to), cost(cost), nm(nm) {}
};
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 100000000;
ll GCD(ll a, ll b){
if(a < b) swap(a, b);
if(b == 0) return a;
return GCD(b, a%b);
}
bool cmp(const pii& a, const pii& b){
if(a.first == b.first){
return a.second < b.second;
}
return a.first < b.first;
}
int main() {
//cout << fixed << setprecision(2);
int n;
cin >> n;
for(int i=0; i<n; ++i){
string s; cin >> s;
int n = s.size();
if(n>2 && s[0] == '>' && s[1] =='\''){
if(s[n-1] != '~'){
cout << "NA" << endl;
}else{
int l = 2, r = n-2;
bool ok = true;
int stmt = 0;
int cnt1=0, cnt2=0;
for(int j=l; j<=r; ++j){
if(s[j] == '#') stmt++;
else if(s[j]=='='){
if(stmt == 0) cnt1++;
else if(stmt == 1) cnt2++;
else ok = false;
}else ok = false;
}
if(ok){
if(cnt1 >= 1 && (cnt1 == cnt2)){
cout << "A" << endl;
}else{
cout << "NA" << endl;
}
}else{
cout << "NA" << endl;
}
}
}else if(n > 2 && s[0] == '>' && s[1] == '^'){
if(s[n-2] == '~' && s[n-1] == '~'){
if(n%2 == 1){
cout << "NA" << endl;
}else {
bool ok = true;
int cnt = 0;
for (int j = 2; j <= n - 3; j+=2) {
if(s[j] == 'Q' && s[j+1] == '='){
cnt++;
}else{
ok = false;
}
}
if(cnt>=1 && ok){
cout << "B" << endl;
}else{
cout << "NA" << endl;
}
}
}else{
cout << "NA" << endl;
}
}else{
cout << "NA" << endl;
}
}
return 0;
}
|
#include<string>
#include<iostream>
using namespace std;
bool isA(string s)
{
int len=s.length();
if(len<6) return false;
if(s.substr(0,2)!=">'") return false;
if(s.substr(len-1)!="~") return false;
s=s.substr(2,len-3);
len=s.length();
if(len%2==0) return false;
if(s[len/2]!='#') return false;
if(s.substr(0,len/2)!=string(len/2,'=')) return false;
if(s.substr(len/2+1)!=string(len/2,'=')) return false;
return true;
}
bool isB(string s)
{
int len=s.length();
if(len<6) return false;
if(s.substr(0,2)!=">^") return false;
if(s.substr(len-2)!="~~") return false;
s=s.substr(2,len-4);
len=s.length();
if(len%2==1) return false;
bool b=true;
for(int i=0;i<len;i+=2){
if(s[i+0]!='Q') b=false;
if(s[i+1]!='=') b=false;
}
return b;
}
int main()
{
int n; cin>>n;
string snake;
while(n--){
cin>>snake;
if (isA(snake)) cout<<'A'<<endl;
else if(isB(snake)) cout<<'B'<<endl;
else cout<<"NA"<<endl;
}
return 0;
}
|
#include <iostream>
#include <algorithm>
using namespace std;
bool isA(const string &s) {
if(s.size() < 6) return false;
if(s.substr(0,2) != ">'") return false;
if(*(s.rbegin()) != '~') return false;
string t = s.substr(2, (int)s.size()-3);
int m = t.find("#");
if(m == string::npos) return false;
if(t.substr(0,m) != string(m, '=')) return false;
if(t.substr(m+1) != string(m, '=')) return false;
return true;
}
bool isB(const string &s) {
if(s.size() < 6) return false;
if(s.substr(0,2) != ">^") return false;
if(s.substr((int)s.size()-2) != "~~") return false;
string t = s.substr(2, (int)s.size()-4);
if(t.size()&1) return false;
for(int i = 0; i < t.size(); i += 2) {
if(t[i] != 'Q' || t[i+1] != '=') return false;
}
return true;
}
int main() {
int n;
cin >> n;
while(n--) {
string s;
cin >> s;
if(isA(s)) cout << "A" << endl;
else if(isB(s)) cout << "B" << endl;
else cout << "NA" << endl;
}
return 0;
}
|
#include<iostream>
#include<string>
using namespace std;
string makeSnakeA( int a )
{
string s = ">\'";
for( int i = 0; i < a; i++ )
s += "=";
s += "#";
for( int i = 0; i < a; i++ )
s += "=";
s += "~";
return s;
}
string makeSnakeB( int a )
{
string s = ">^";
for( int i = 0; i < a; i++ )
s += "Q=";
s += "~~";
return s;
}
int main()
{
int n;
string str, s[200], t[200];
for( int i = 0; i < 200; i++ )
{
s[i] = makeSnakeA( i + 1 );
t[i] = makeSnakeB( i + 1 );
}
cin >> n;
for( int i = 0; i < n; i++ )
{
cin >> str;
int size = str.size();
if( size >= 6 && s[(size-6)/2] == str )
cout << "A" << endl;
else if( size >= 6 && t[(size-6)/2] == str )
cout << "B" << endl;
else
cout << "NA" << endl;
}
return 0;
}
|
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define fr first
#define sc second
#define mp make_pair
#define foreach(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;
int main(){
int N;
cin >> N;
while(N--) {
string s; cin >> s;
if(s[0] != '>') {
cout << "NA" << endl;
continue;
}
int select = 0;
if(s[1] == '\'') {
int cnt = 0;
if(!(s.size() % 2)) {
for(int i = 2; i < s.size() / 2; i++) {
if(s[i] != '=') {
select = -1;
break;
}
cnt++;
}
if(~select && !cnt) {
cout << "NA" << endl;
continue;
}
for(int i = s.size() / 2 + 1; i < s.size() - 1; i++) {
if(s[i] != '=') {
select = -1;
break;
}
cnt--;
}
} else select = -1;
if(!cnt && ~select && s[s.size() / 2] == '#' && s[s.size() - 1] == '~')
cout << "A" << endl;
else cout << "NA" << endl;
} else if(s[1] == '^') {
if(!(s.size() % 2)) {
for(int i = 2; i < s.size() - 2; i++) {
if((!(i % 2) && s[i] != 'Q') || (i % 2 && s[i] != '=')) {
select = -1;
break;
}
}
if(s.size() >= 6 && ~select && s[s.size() - 1] == s[s.size() - 2] && s[s.size() - 1] == '~') cout << "B" << endl;
else cout << "NA" << endl;
} else cout << "NA" << endl;
} else {
cout << "NA" << endl;
}
}
}
|
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
int main()
{
// cut here before submit
// freopen ("testcase.snack", "r", stdin );
const string species[] = { "A", "B", "NA" };
string str = "";
int n;
while (getline (cin, str ) ){
stringstream ssn(str);
ssn >> n;
// cout << "n: " << n << endl;
if (n == 0 ){
break;
} // end if
int i,j;
for (i = 0; i < n; ++i){
string res = species[2];
getline (cin, str );
if (str.empty() ){
break;
} // end if
int len = str.length();
if (str[0] == '>'){
if (str[1] == '\''){ // A species?
res = species[0];
}else if (str[1] == '^'){ // B species?
res = species[1];
}else{ // new species.
res = species[2];
} // end if
} // end if
if (res == species[0] || res == species[1]){
if (res == species[0]){ // A species?
int prev = 0;
int after = 0;
int mid = 0;
bool flag = false;
for (j = 2; j < len - 1; ++j){
if (str[j] == '='){
if (!flag){
++prev;
}else{
++after;
} // end if
continue;
}else if (str[j] == '#'){
flag = true;
++mid;
continue;
}else{
break;
} // end if
} // end for
if (j == len - 1){
if (str[j] == '~' && flag && mid == 1
&& prev != 0 && after != 0 && prev == after ){
res = species[0];
}else{
res = species[2];
} // end if
}else{
res = species[2];
} // end if
}else{ // if (res == species[1]) // B species?
bool flag = false;
for (j = 2; j < len - 2; j += 2){
if (str[j] == 'Q' && str[j+1] == '='){
if (!flag ){
flag = true;
} // end if
continue;
}else{
break;
} // end if
} // end for
if (j == len - 2 && flag && str[j] == '~' && str[j+1] == '~'){
res = species[1];
}else{
res = species[2];
} // end if
} // end if
} // end if
cout << res << endl;
} // end for
} // end loop
return 0;
}
|
#include <iostream>
#include <algorithm>
using namespace std;
string judgeSnakeType(string s){
if(s.find( ">'") == 0 && s.find("~") == s.size()-1)
{
s.erase(s.size()-1,1); s.erase(0,2);
int cnt = 0;
if( s.size() == 0 ) return "NA";
while( s.size() > 0 && s[0] == '=' ){
if(s[0] == '='){
s.erase(0,1);
cnt++;
}
}
if( s[0] != '#' || cnt == 0)return "NA";
s.erase(0,1);
while( s.size() > 0 && s[0] == '=' ){
if(s[0] == '='){
s.erase(0,1);
cnt--;
}
}
if(s.size() == 0 && cnt == 0) return "A";
else return "NA";
}
else if( s.find( ">^") == 0 && s.find("~~") == s.size()-2)
{
s.erase(s.size()-2,2); s.erase(0,2);
if( s.size() == 0 ) return "NA";
while( s.size() > 0 && s.size() % 2 == 0){
if(s[0] == 'Q' && s[1] == '='){
s.erase(0,2);
}
else {
return "NA";
}
}
return s == "" ? "B" : "NA";
}
else
{
return "NA";
}
return "NA";
}
void solve(string snake){
cout << judgeSnakeType( snake ) << endl;
}
int main(){
int d;
cin >> d;
string snake;
for(int i = 0 ; i < d; i++ )
{
cin >> snake;
solve(snake);
}
return 0;
}
|
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))
typedef long long int ll;
using namespace std;
bool isa(string s){
if(s.substr(0,2) != ">'") return false;
int x = 2;
int c = 0;
while(s[x+c] == '='){
c++;
}
if(s[x+c] != '#') return false;
x = x + c + 1;
for(int i=0;i<c;i++){
if(s[x+i] != '=') return false;
}
x += c;
if(s[x] != '~') return false;
return true;
}
bool isb(string s){
if(s[0] != '>') return false;
if(s[1] != '^') return false;
int x = 2;
int c = 0;
while(s[x+c] == 'Q' && s[x+1+c] == '='){
c += 2;
}
x += c;
if(s[x] != '~') return false;
if(s[x+1] != '~') return false;
return true;
}
int main(){
string s = "";
int n;
cin >> n;
REP(i,n){
cin >> s;
if(s.size() < 6){
cout << "NA" << endl;
continue;
}
if(isa(s)) cout << "A"<<endl;
else if(isb(s)) cout << "B" << endl;
else cout << "NA" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(){
char buf[210];
int bi,n,eqc,ti;
cin >> n;
for (int i=0;i<n;i++){
bi=0;
cin >> buf;
if (buf[bi++]!='>') {
cout << "NA" << endl;
continue;
}
if (buf[bi]=='\''){
bi++;
eqc=0;
if (buf[bi]!='='){
cout << "NA" << endl;
continue;
}
while (buf[bi+eqc]=='=')eqc++;
if (buf[bi+eqc]!='#'){
cout << "NA" << endl;
continue;
}
bi += eqc+1;
for (ti=0;ti<eqc;ti++)
if (buf[bi+ti]!='=')break;
if (ti <eqc){
cout << "NA" << endl;
continue;
}
bi+=ti;
if (buf[bi]=='~'&&buf[bi+1]=='\0')cout << "A" << endl;
else cout << "NA" << endl;
}else if(buf[bi]=='^'){
bi++;
//cout <<"dbg "<< buf[bi] << buf[bi+1] << endl;
if(buf[bi]!='Q'||buf[bi+1]!='='){
cout << "NA" << endl;
continue;
}
bi+=2;
while (buf[bi]=='Q'&&buf[bi+1]=='=')bi +=2;
//cout <<"dbg "<< buf[bi] << buf[bi+1] << endl;
if (buf[bi]=='~'&&buf[bi+1]=='~'){
if (buf[bi+2]=='\0')cout << "B" << endl;
else cout << "NA" << endl;
}else cout << "NA" << endl;
}else{
cout << "NA" << endl;
continue;
}
}
return 0;
}
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
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
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;
typedef pair<int, string> PSI;
int n;
string s;
bool F;
int main(){
cin >> n;
REP(i, n){
F = 0;
cin >> s;
if (s[0] == '>'&&s[s.size() - 1] == '~'){
if (s[1] == '\''){
int icnt = 0;
bool f = 1;
FOR(j, 2, s.size() - 1){
if (s[j] == '='){
if (f){
icnt++;
}
else{
icnt--;
}
}
else if (s[j] == '#'){
if (f)f = 0;
else {
F = 1;
break;
}
}
else{
F = 1;
break;
}
}
if (F == 0 && icnt == 0 && s.size() >= 6){
cout << "A" << endl;
}
else {
cout << "NA" << endl;
}
}
else if (s[1] == '^'&&s.size() % 2 == 0 && s.size() >= 6
&& s[s.size() - 1] == '~'&&s[s.size() - 2] == '~'){
FOR(j, 2, s.size() - 2){
if (j % 2 == 0){
if (s[j] != 'Q'){
F = 1;
break;
}
}
else{
if (s[j] != '='){
F = 1;
break;
}
}
}
if (F){
cout << "NA" << endl;
}
else{
cout << "B" << endl;
}
}
else {
cout << "NA" << endl;
}
}
else{
cout << "NA" << endl;
}
}
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
string a;
cin >> a;
if (a.substr(0, 2) == ">'") {
int counter = 0;
bool hantei = false;
int i;
for (i = 2; i < a.size(); i++) {
if (a[i] == '=') {
counter++;
} else if (a[i] == '#' && counter > 0) {
hantei = true;
break;
} else {
hantei = false;
break;
}
}
if (hantei) {
int j;
for (j = i+1; j < a.size(); j++) {
if (a[j] == '=') {
counter--;
} else if (a[j] == '~') {
hantei = true;
break;
} else {
hantei = false;
break;
}
}
if (hantei) {
if (counter == 0 && j == a.size()-1) {
cout << 'A' << endl;
} else {
cout << "NA" << endl;
}
} else {
cout << "NA" << endl;
}
} else {
cout << "NA" << endl;
}
} else if (a.substr(0, 2) == ">^") {
int i;
bool hantei = false;
for (i = 2; i < a.size()-1; i += 2) {
if (a.substr(i, 2) == "Q=") {
hantei = true;
} else if (a.substr(i, 2) == "~~" && i == a.size()-2 && hantei) {
hantei = true;
break;
} else {
hantei = false;
break;
}
}
if (hantei) {
cout << 'B' << endl;
} else {
cout << "NA" << endl;
}
}else {
cout << "NA" << endl;
}
}
return 0;
}
|
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
bool b;
int n, i, j, t, c[2];
char s[201];
cin >> n;
for (i = 0; i < n; i++)
{
b = true;
cin >> s;
if (s[0] == '>')
{
if (s[1] == '\'')
{
for (j = 2, t = c[0] = c[1] = 0; j < strlen(s)-1; j++)
{
if (s[j] == '=')
c[t]++;
else if (t == 0 && s[j] == '#')
t++;
else
{
b = false;
break;
}
}
if (b && c[0] > 0 && c[0] == c[1] && s[strlen(s)-1] == '~')
cout << "A" << endl;
else
cout << "NA" << endl;
continue;
}
else if (s[1] == '^')
{
for (j = 2, c[0] = 0; j < strlen(s)-2; j+=2)
{
if (s[j] != 'Q' || s[j+1] != '=')
{
b = false;
break;
}
else
c[0]++;
}
if (b && c[0] > 0 && s[strlen(s)-2] == '~' && s[strlen(s)-1] == '~')
cout << "B" << endl;
else
cout << "NA" << endl;
continue;
}
else
b = false;
}
else
b = false;
if (!b)
cout << "NA" << endl;
}
}
|
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
int n,i,j,s;
string c1,c2,c3;
cin >> n;
for (i=0;i<n;i++) {
cin >> c1;
c2=c3=c1;
s=c1.size();
if (s<6 || s % 2==1) { cout << "NA" << endl; continue; }
for (j=0;j<s;j++) c2[j]=c3[j]='=';
c2[0]=c3[0]='>'; c2[s-1]=c3[s-1]=c3[s-2]='~';
c2[1]='\''; c2[s/2]='#'; c3[1]='^';
for (j=2;j<s-2;j+=2) c3[j]='Q';
if (c1==c2) cout << 'A'; else if (c1==c3) cout << 'B'; else cout << "NA";
cout << endl;
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
char buf[1024];
int M;
bool checkA(){
if( buf[0] != '>' ) return false;
if( buf[1] != '\'') return false;
int cnt1=0,cnt2=0;
bool f = false;
int i;
for(i=2;i<M;i++){
if(!f){
if( buf[i] == '=' ) cnt1++;
else if( buf[i] == '#' ) f = true;
else return false;
} else {
if( buf[i] == '=' ) cnt2++;
else break;
}
}
if( buf[i] != '~' ) return false;
i++;
if( i == M && cnt1 == cnt2 && cnt1>0 && f ) return true;
return false;
}
bool checkB(){
if( buf[0] != '>' ) return false;
if( buf[1] != '^' ) return false;
int i;
bool f = false;
for(i=2;i<M-2;i+=2){
if( buf[i] != 'Q' ) return false;
if( buf[i+1] != '=' ) return false;
f = true;
}
if( f && buf[i] == '~' && buf[i+1] == '~' && i + 2 == M ) return true;
return false;
}
int main(){
int n; cin >> n;
for(int i=0;i<n;i++){
cin >> buf; M = strlen(buf);
if( checkA() ) cout << "A" << endl;
else if( checkB() ) cout << "B" << endl;
else cout << "NA" << endl;
}
}
|
#include<iostream>
#include<string>
using namespace std;
string S;
int n;
string solve(string T) {
int chain = 0, ok = 0;
if (T.size() >= 3) {
if (T[T.size() - 1] == '~') {
if (T.substr(0, 2) == ">'" && T.size() >= 6) {
for (int i = 2; i < T.size() - 1; i++) {
if (T[i] == '#') {
ok++;
}
else if (T[i] == '=') {
if (ok == 0) { chain++; }
else { chain--; }
}
else {
goto NA;
}
}
if (ok == 1 && chain == 0) { return "A"; }
}
if (T.substr(0, 2) == ">^" && T[T.size() - 2] == '~' && T.size() >= 6) {
for (int i = 2; i < T.size() - 2; i += 2) {
if (T.substr(i, 2) != "Q=") {
goto E;
}
}
return "B";
E:;
}
}
}
NA:;
return "NA";
}
int main() {
cin >> n;
for (int h = 0; h < n; h++) {
cin >> S;
cout << solve(S) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
bool isOutOfStr(int ind, string str){
return ind >= str.length();
}
int main(void){
int n;
cin >> n;
while(n--){
string str; cin >> str;
if(!isOutOfStr(1, str) &&str[0] == '>' && str[1] == '\''){
int sharp_cnt = 0;
int ind;
ind = 2;
if(isOutOfStr(ind, str) || str[ind] != '='){
cout << "NA" << endl;
continue;
}
for(;;ind++){
if(isOutOfStr(ind, str) || str[ind] != '='){
break;
}
sharp_cnt++;
}
if(isOutOfStr(ind, str) || str[ind] != '#'){
cout << "NA" << endl;
continue;
}
ind++;
bool flg = true;
for(int i=0; i < sharp_cnt; i++, ind++){
if(isOutOfStr(ind, str) || str[ind] != '='){
cout << "NA" << endl;
flg = false;
break;
}
}
if(!flg) continue;
if(!isOutOfStr(ind, str) && str[ind] == '~' && ind == str.length() - 1)
cout << "A" << endl;
else{
cout << "NA" << endl;
}
}else if(str[0] == '>' && str[1] == '^'){
int ind;
ind=2;
if(isOutOfStr(ind, str) || !(str[ind] == 'Q' && str[ind+1] == '=')){
cout << "NA" << endl;
}else{
int flg = true;
for(;;ind+=2){
if(isOutOfStr(ind, str) || !(str[ind] == 'Q' && str[ind+1] == '=')){
break;
}
}
if(!isOutOfStr(ind, str) && !isOutOfStr(ind+1, str) && str[ind] == '~' && str[ind+1] == '~' && ind+1 == str.length() - 1){
cout << "B" << endl;
}else{
cout << "NA" << endl;
}
}
}else{
cout << "NA" << endl;
}
}
return 0;
}
|
#include<iostream>
#include<string>
using namespace std;
int main(){
int f,i,m;
string s;
for(cin>>f;cin>>s;f?puts(f-2?"A":"B"):puts("NA")){
f=0;
if(s[0]+s[1]==101){
if((m=s.find(35))!=string::npos)
for(i=1;s[m-i]==s[m+i];)
if(m-++i==1 && m+i==s.size()-1 && s[m+i]=='~')f=1;
}else if(s[0]+s[1]==156){
for(i=2;s[i]=='Q'&&s[i+1]=='=';)
if(++++i==s.size()-2 && s[i]+s[i+1]==252)f=2;
}
}
}
|
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
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()
{
int n;
cin >> n;
for(int i=0;i<n;i++)
{
string s;
cin >> s;
int sz=s.size();
if(s[0]!='>'||sz<6)
{
cout << "NA" << endl;
continue;
}
if(s[1]=='\'')
{
int t=sz-3;
if(t%2==0)
{
cout << "NA" << endl;
continue;
}
for(int j=2;j<2+t;j++)
{
if(j==2+t/2&&s[j]!='#')
{
cout << "NA" << endl;
goto end;
}
else if(j!=2+t/2&&s[j]!='=')
{
cout << "NA" << endl;
goto end;
}
}
if(s[sz-1]!='~')
{
cout << "NA" << endl;
continue;
}
cout << "A" << endl;
end:;
}
else if(s[1]=='^')
{
int t=sz-4;
if(t%2==1)
{
cout << "NA" << endl;
continue;
}
for(int j=0;j<t;j++)
{
if(j%2==0&&s[j+2]!='Q')
{
cout << "NA" << endl;
goto end2;
}
else if(j%2==1&&s[j+2]!='=')
{
cout << "NA" << endl;
goto end2;
}
}
if(s[sz-1]!='~'||s[sz-2]!='~')
{
cout << "NA" << endl;
continue;
}
cout << "B" << endl;
end2:;
}
else
{
cout << "NA" << endl;
continue;
}
}
return 0;
}
|
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
using namespace std;
int main() {
int a;
cin >> a;
for (int b = 0; b < a; b++) {
string c; cin >> c;
if ((c.length() & 1)==0&&c.length()>=6) {
if (c[0] == '>'&&c[1] == '^'&&c[c.length() - 1] == '~'&&c[c.length() - 2] == '~') {
bool e = true;
for (int d = 2; d < c.length() - 2; d += 2) {
if (c[d] != 'Q' || c[d + 1] != '=')e = false;
}
if (e) {
puts("B");
continue;
}
}
if (c[0] == '>'&&c[1] == '\''&&c[c.length() - 1] == '~') {
bool k = true;
for (int j = 2; j < c.length() - 1; j++) {
if (j == c.length() / 2) {
if (c[j] != '#')k = false;
}
else {
if (c[j] != '=')k = false;
}
}
if (k) { puts("A"); continue; }
}
}
puts("NA");
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
int main() {
int N;
cin >> N;
REP(n, N) {
string str;
int type = 0, pos = 0;
cin >> str;
if (str[pos] == '>') {
pos++;
if (str[pos] == '\'') {
pos++;
int cnt = 0;
while (pos < str.size() && str[pos] == '=') { cnt++; pos++; }
if (cnt != 0 && str[pos] == '#') {
pos++;
while (pos < str.size() && str[pos] == '=') { cnt--; pos++; }
if (cnt == 0 && str[pos] == '~') type = 1;
}
}
else if (str[pos] == '^') {
bool f = false;
pos++;
while (pos + 1 < str.size()) {
if (str[pos] == 'Q' && str[pos + 1] == '=') { pos += 2; f = true; }
else break;
}
if (f && pos + 2 == str.size() && str[pos] == '~' && str[pos + 1] == '~')
type = 2;
}
}
switch (type) {
case 0: cout << "NA" << endl; break;
case 1: cout << "A" << endl; break;
case 2: cout << "B" << endl; break;
}
}
return 0;
}
|
#include <bits/stdc++.h>
#include <regex>
using namespace std;
string Sample;
//const regex REA("^>'(=+)#\1~$"), REB("^>\\^(Q=)+~~$");
const regex REA("^>'(=+)#(=+)~$"), REB("^>\\^(Q=)+~~$");
int main() {
int n;
smatch smStr;
cin >> n;
while (n--) {
cin >> Sample;
//cout << Sample << endl;
if (regex_match(Sample, smStr, REA)) {
if (smStr[1].length() == smStr[2].length()) {
cout << "A" << endl;
}
else {
cout << "NA" << endl;
}
}
else if (regex_match(Sample, REB)) {
cout << "B" << endl;
}
else {
cout << "NA" << endl;
}
}
return 0;
}
|
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int main(void){
int n;
cin>>n;
while(n--){
string snake;
cin>>snake;
if(snake[0]=='>'&&snake[1]=='\''&&snake[snake.size()-1]=='~'){
int count=0;
int end;
for(int i=2;i<snake.size()&&snake[i]=='='; i++){
count++;
end = i;
}
end++;
if(count&&snake[end]=='#'&&end+count+2==snake.size()){
bool yes = true;
for(int i=end+1;i<snake.size()-1;i++){
if(snake[i]!='=')yes = false;
}
if(yes){
cout<<"A"<<endl;
}else{
cout<<"NA"<<endl;
}
}else{
cout<<"NA"<<endl;
}
}else if(snake[0]=='>'&&snake[1]=='^'&&snake[snake.size()-1]=='~'&&snake[snake.size()-2]=='~'
&&snake[snake.size()-3]=='='){
bool yes = true;
for(int i=2;i<snake.size()-2;i++){
if(i%2==0&&snake[i]!='Q') yes = false;
if(i%2==1&&snake[i]!='=') yes = false;
}
if(yes){
cout<<"B"<<endl;
}else{
cout<<"NA"<<endl;
}
}else{
cout<<"NA"<<endl;
}
}
return 0;
}
|
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
int main()
{
int n;
cin >> n;
while(--n >= 0){
string s;
cin >> s;
int n = s.size();
if(n < 6 || n % 2 == 1){
cout << "NA" << endl;
continue;
}
string sa(n, '=');
sa[0] = '>';
sa[1] = '\'';
sa[n/2] = '#';
sa[n-1] = '~';
if(s == sa){
cout << 'A' << endl;
continue;
}
string sb(n, '=');
sb[0] = '>';
sb[1] = '^';
for(int i=2; i<n-2; i+=2)
sb[i] = 'Q';
sb[n-2] = '~';
sb[n-1] = '~';
if(s == sb)
cout << 'B' << endl;
else
cout << "NA" << endl;
}
return 0;
}
|
#include <iostream>
int main()
{
std::string sn; getline(std::cin, sn);
int n = std::stoi(sn);
for (int i=0; i<n; i++) {
std::string snake;
getline(std::cin, snake);
int state = 0;
int equal_count = 0;
for (int k=0; k<snake.length(); k++) {
char c = snake[k];
switch (state) {
case 0:
if (c == '>') state = 1;
else state = 9;
break;
case 1:
if (c == '\'') state = 10;
else if (c == '^') state = 11;
else state = 9;
break;
case 2:
if (c == '=') equal_count++;
else if (c == '#') state = 3;
else state = 9;
break;
case 3:
if (c == '=') {
equal_count--;
if (equal_count < 0) state = 9;
}
else if (equal_count == 0 && c == '~') state = 4;
else state = 9;
break;
case 4:
state = 9;
break;
case 5:
if (c == 'Q') state = 6;
else if (c == '~') state = 7;
else state = 9;
break;
case 6:
if (c == '=') state = 5;
else state = 9;
break;
case 7:
if (c == '~') state = 8;
else state = 9;
break;
case 8:
state = 9;
break;
case 10:
if (c == '=') {
equal_count++; state = 2;
}
else state = 9;
break;
case 11:
if (c == 'Q') state = 12;
else state = 9;
break;
case 12:
if (c == '=') state = 5;
else state = 9;
break;
}
}
if (state == 4) std::cout << "A" << std::endl;
else if (state == 8) std::cout << "B" << std::endl;
else std::cout << "NA" << std::endl;
}
return 0;
}
|
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#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;
}
}
|
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int N;
cin>>N;
for(int i=0;i<N;i++){
string sn;
cin>>sn;
int type=0;
if(sn[0]=='>'&&sn[1]==39)type=1;
if(sn[0]=='>'&&sn[1]=='^')type=2;
int flg=1;
if(type==1){
int cou=0;
int aftercou=0;
int p;
for(int j=2;j<sn.size();j++){
if(sn[j]=='=')cou++;
else if(sn[j]=='#'){
p=j;
break;
}
else{
flg=0;
goto syutu;
}
}
for(int k=p+1;k<sn.size();k++){
if(sn[k]=='=')aftercou++;
else if(sn[k]=='~'&&k==sn.size()-1){
if(cou!=aftercou)flg=0;
goto syutu;
}
else{
flg=0;
goto syutu;
}
}
if(sn[sn.size()-1]!='~')flg=0;
syutu:
if(flg&&cou)puts("A");
else puts("NA");
}
else if(type==2){
for(int j=2;j<sn.size()-1;j+=2){
if(sn[j]=='~'&&sn[j+1]=='~'&&j!=2)break;
if(!(sn[j]=='Q'&&sn[j+1]=='='))flg=0;
}
if(sn[sn.size()-2]!='~'||sn[sn.size()-1]!='~')flg=0;
if(flg)puts("B");
else puts("NA");
}
else puts("NA");
}
return 0;
}
|
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
int n,length,second_length;
char snake[201];
scanf("%d",&n);
for(int i=0; i < n; i++){
scanf("%s",snake);
if(snake[1] == '\0'){
printf("NA\n");
continue;
}
if(snake[0] == '>' && snake[1] == '\''){
if(snake[2] != '='){
printf("NA\n");
}else{
for(length = 0;snake[length+2] != '\0' && snake[length+2] == '='; length++);
if(snake[length+2] != '#'){
printf("NA\n");
}else{
for(second_length = 0; snake[length+3+second_length] != '\0' &&
snake[length+3+second_length] == '=';second_length++);
if(length != second_length || snake[length+3+second_length] != '~'){
printf("NA\n");
}else{
if(snake[length+4+second_length] == '\0'){
printf("A\n");
}else{
printf("NA\n");
}
}
}
}
}else if(snake[0] == '>' && snake[1] == '^'){
if(snake[2] != 'Q' || snake[3] != '='){
printf("NA\n");
}else{
bool breakFLG = false;
for(length=0;snake[length+2] != '\0' && (snake[length+2] == 'Q' || snake[length+2] == '=');length++){
if(length > 1){
if(snake[length+2] == 'Q' && snake[length+2-1] != '='){
breakFLG = true;
break;
}
if(snake[length+2] == '=' && snake[length+2-1] != 'Q'){
breakFLG = true;
break;
}
}
}
if(breakFLG)printf("NA\n");
else{
if(snake[length+2-1] == 'Q'|| snake[length+2] != '~'){
printf("NA\n");
}else{
if(snake[length+3] != '~'){
printf("NA\n");
}else{
if(snake[length+4] == '\0'){
printf("B\n");
}else{
printf("NA\n");
}
}
}
}
}
}else{
printf("NA\n");
}
}
return 0;
}
|
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n;
cin>>n;
while(n--){
string s;
cin>>s;
if(s[0]=='>'){
if(s[1]=='\''){
int sum=0;
if(s.size()<6)goto L;
r(i,s.size())if(s[i]=='=')sum++;
if(s.size()%2==0&&s[s.size()/2]=='#'&&sum==s.size()-4&&s[s.size()-1]=='~')
cout<<'A'<<endl;
else goto L;
}
else if(s[1]=='^'){
int c=2;
if(s.size()%2||s.size()<6)goto L;
while(c<s.size()-3){
if(s[c]!='Q')goto L;
c++;
if(s[c]!='=')goto L;
c++;
}
if(s[c]=='~'&&s[c+1]=='~')cout<<'B'<<endl;
else goto L;
}
else goto L;
}
else goto L;
if(0)L:cout<<"NA"<<endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
static inline int in(){ int x; scanf("%d", &x); return x; }
int main()
{
int n = in();
int am[12][256] = {};
am[1]['>'] = 2;
am[2]['\''] = 3;
am[3]['='] = 4;
am[4]['='] = 4;
am[4]['#'] = 5;
am[5]['='] = 5;
am[5]['~'] = 6;
am[2]['^'] = 7;
am[7]['Q'] = 8;
am[8]['='] = 9;
am[9]['Q'] = 8;
am[9]['~'] = 10;
am[10]['~'] = 11;
const int typeA = 6;
const int typeB = 11;
for (int i = 0; i < n; i++){
string snake;
cin >> snake;
int aid = 1;
int c4, c5;
c4 = c5 = 0;
for (int j = 0; j < snake.size(); j++){
aid = am[aid][snake[j]];
if (aid == 4) c4++;
if (aid == 5) c5++;
}
if (aid == typeA && c4 == c5 - 1){
puts("A");
}
else if (aid == typeB){
puts("B");
}
else {
puts("NA");
}
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main(){
int i,j,n,a;
string str,ans;
cin >> n;
for(i=0;i<n;i++){
cin >> str;
ans = "NA";
if(str[0] == '>'){
if(str[1] == '\''){
a = 2;
int c=0,c2=0;
if(str[a] == '='){
while(str[a] == '='){
a++;
c++;
}
if(str[a] == '#'){
a++;
if(str[a] == '='){
while(str[a] == '='){
c2++;
a++;
}
if(str[a] == '~' && a + 1 == str.size() && c == c2) ans = "A";
}
}
}
}
else if(str[1] == '^'){
a = 2;
if(str[a] == 'Q' && str[a+1] == '='){
while(str[a] == 'Q' && str[a+1] == '=') a += 2;
if(str[a] == '~' && str[a+1] == '~' && a + 2 == str.size()) ans = "B";
}
}
}
cout << ans << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int n;
int main()
{
cin >> n;
for (int i = 0; i < n; i++) {
string s, t, w;
cin >> s;
t = "NA";
int m = s.size();
if (m > 4 && m % 2 == 0) {
string u(m - 4, '=');
u.insert(u.begin() + m / 2 - 2, '#');
if (s == ">'" + u + '~')
t = "A";
for (int j = 0; j < (m / 2 - 2); j++)
w += "Q=";
if (s == ">^" + w + "~~")
t = "B";
}
cout << t << endl;
}
return 0;
}
|
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
using namespace std;
#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
bool isA(const char* str)
{
int n = strlen(str);
if(n<6) return false;
if(str[0]!='>' || str[1]!='\'') return false;
int cnt, i;
for(cnt=0, i=2; i<n && str[i]=='='; ++cnt, ++i);
if(cnt==0 || i>=n || str[i] != '#') return false;
++i;
int s;
for(s=0; i<n && str[i]=='='; ++s, ++i);
if(cnt!=s || i+1!=n) return false;
return str[i] == '~';
}
bool isB(const char* str)
{
int n = strlen(str);
if(n<6) return false;
if(str[0]!='>' || str[1]!='^') return false;
int i;
for(i=2; i+1<n && str[i]=='Q' && str[i+1]=='='; i+=2);
if(i==2 || i+2!=n) return false;
return str[i]=='~' && str[i+1] == '~';
}
int main()
{
int n;
scanf("%d", &n);
rep(i, n){
char str[256];
scanf("%s", str);
if(isA(str))
puts("A");
else if(isB(str))
puts("B");
else
puts("NA");
}
return 0;
}
|
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;
bool isA(string s){
int n = 0;
if(s.at(n)!='>' || s.at(++n)!='\'' ||s.at(++n)!='=') return false;
int cnt = 1;
for(;s.at(++n)=='='; cnt++);
if(s.at(n)!='#') return false;
for(int i=0; i<cnt; i++){
if(s.at(++n)!='=') return false;
}
if(s.at(++n)!='~' || s.size()>n+1) return false;
return true;
}
bool isB(string s){
int n = 0;
if(s.at(n)!='>' || s.at(++n)!='^' || s.at(++n)!='Q' || s.at(++n)!='=') return false;
while(true){
if(s.at(++n)=='Q'){
if(s.at(++n)!='=') return false;
}
else break;
}
if(s.at(n)!='~' || s.at(++n)!='~' || s.size()>n+1) return false;
return true;
}
int main(){
string S;
int N;
cin>>N;
for(int i=0;i<N;i++){
cin>>S;
if(isA(S)) puts("A");
else if(isB(S)) puts("B");
else puts("NA");
}
return 0;
}
|
#include<iostream>
#include<string>
using namespace std;
bool isA(string &s){
if(s.size()<6)return false;
if(s[0]!='>'||s[1]!='\'')return false;
int i=2;
while(s[i]=='=')i++;
int cnt=i-2;
if(cnt==0||s[i]!='#')return false;
for(i++;i<s.size()&&s[i]=='=';i++)cnt--;
if(cnt||i==s.size()||s[i]!='~')return false;
return i+1==s.size();
}
bool isB(string &s){
if(s.size()<6)return false;
if(s[0]!='>'||s[1]!='^')return false;
int i=2;
for(;i<s.size()&&s[i]=='Q';){
if(i+1<s.size()&&s[i+1]=='=')i+=2;
else break;
}
if(i==2)return false;
if(i+2==s.size()&&s[i]=='~'&&s[i+1]=='~')return true;
return false;
}
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
string s;
cin>>s;
if(isA(s))cout<<"A\n";
else if(isB(s))cout<<"B\n";
else cout<<"NA\n";
}
return 0;
}
|
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
while(n--){
string str;
cin>>str;
if(str[0]!='>')cout<<"NA"<<endl;
else{
if(str[1]=='\''&&str[2]=='='){
int e=2;
for(;str[e]=='=';e++);
if(str[e]=='#'){
int f=e+1;
for(;str[f]=='=';f++);
if(e==f-e+1&&str[f]=='~'&&str[f+1]=='\0')cout<<"A"<<endl;
else cout<<"NA"<<endl;
}
else cout<<"NA"<<endl;
}
else if(str[1]=='^'&&str[2]=='Q'){
int e,flg=0;
for(e=2;str[e]=='Q';e+=2){
if(str[e+1]!='='){
cout<<"NA"<<endl;
flg=1;
break;
}
}
if(!flg){
if(str[e]=='~'&&str[e+1]=='~'&&str[e+2]=='\0')cout<<"B"<<endl;
else cout<<"NA"<<endl;
}
}
else cout<<"NA"<<endl;
}
}
return 0;
}
|
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())
typedef unsigned long long ull;
int Judge(string &s){
if(s[0] != '>') return -1;
if(s.size() < 2) return -1;
if(s[1] == '\''){
if(s[s.size()-1] != '~') return -1;
int len = sz(s) - 3;
if(len < 3 || len % 2 == 0) return -1;
FOR(i,(len-1)/2){
if(s[2+i] != '=' || s[2+len/2+1+i] != '=') return -1;
}
if(s[2+len/2] != '#') return -1;
return 0;
} else if(s[1] == '^'){
if(s[s.size()-1] != '~' || s[s.size()-2] != '~')return -1;
int len = sz(s) - 4;
if(len < 2 || len % 2 != 0) return -1;
FOR(i,len/2){
if(s[2+2*i] != 'Q' || s[2+2*i+1] != '=') return -1;
}
return 1;
} else {
return -1;
}
}
int main(){
int n; cin>>n;
string out[] = {"NA","A","B"};
FOR(i,n){
string s; cin>>s;
int a = Judge(s);
cout << out[a+1] << endl;
}
return 0;
}
|
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
int main(){
int n;
cin>>n;
for(int i = 0; i < n; i++){
string str;
cin>>str;
if(str.size()<=4)
cout<<"NA"<<endl;
else if(str.substr(0,2)==">'"&&str[str.size()-1]=='~'&&str.size()%2==0){
string ss=str.substr(2,str.size()-3);
if(ss.size()>=3){
bool f=true;
for(int j = 0; j < ss.size(); j++){
if(j==0){
if(ss[j]!='='){
f=false;
break;
}
}
else if(j==(ss.size()/2)){
if(ss[j]!='#'){
f=false;
break;
}
}
else{
if(ss[j]!='='){
f=false;
break;
}
}
}
if(f)
cout<<"A"<<endl;
else
cout<<"NA"<<endl;
}
else{
cout<<"NA"<<endl;
}
}
else if(str.substr(0,2)==">^"&&str.substr(str.size()-2,2)=="~~"&&str.size()%2==0){
string ss=str.substr(2,str.size()-4);
bool f=true;
if(ss.size()>=2){
for(int j = 0; j < ss.size(); j+=2){
if(ss.substr(j,2)!="Q="){
f=false;
break;
}
}
if(f)
cout<<"B"<<endl;
else
cout<<"NA"<<endl;
}
else
cout<<"NA"<<endl;
}
else
cout<<"NA"<<endl;
}
return 0;
}
|
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int i,j;
int n;
vector<string> s;
cin>>n;
for(i=0;i<n;i++){
string str;
cin>>str;
s.push_back(str);
}
for(i=0;i<n;i++){
if(s[i].find(">'")==0){
if(s[i].find("~")==s[i].length()-1){
if(s[i].find("#")!=-1){
if(s[i].find("#")-2==s[i].length()-s[i].find("#")-2){
int len;
string str;
str=s[i].substr(2,s[i].find("#")-2);
len=str.length();
if(len>0){
for(j=0;j<len;j++){
if(str[j]!='=')
break;
}
if(j==len){
str=s[i].substr(s[i].find("#")+1,s[i].find("#")-2);
len=str.length();
for(j=0;j<len;j++){
if(str[j]!='=')
break;
}
if(j==len){
cout<<"A"<<endl;
continue;
}
}
}
}
}
}
}else if(s[i].find(">^")==0){
if(s[i].find("~~")==s[i].length()-2){
int len;
string str;
str=s[i].substr(2,s[i].length()-4);
len=str.length();
if(len>1&&len%2==0){
for(j=0;j<len;j+=2){
if(str[j]!='Q')
break;
}
if(j==len){
for(j=1;j<len;j+=2){
if(str[j]!='=')
break;
}
if(j==len+1){
cout<<"B"<<endl;
continue;
}
}
}
}
}
cout<<"NA"<<endl;
}
return 0;
}
|
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
string str;
int N;
cin>>N;
for(int i=0;i<N;i++){
cin>>str;
string x=" ";
if(str[0]=='>'){
for(int j=0;j<2;j++)
x[j]=str[j];
if(str[1]=='\''&&str[str.size()-1]=='~'){
bool f=true;int C=0;
int mid=(2+str.size()-2)/2;
for(int j=2;j<=str.size()-2;j++)
{if(j!=mid&&str[j]!='='){f=false;}
else if(j==mid&&str[j]!='#')f=false;
if(str[j]=='=')C++;
}
if(C%2!=0||C==0)f=false;
if(f==true)cout<<"A"<<endl;
else cout<<"NA"<<endl;
}
else if(str[1]=='^'&&str[str.size()-1]=='~'&&str[str.size()-2]=='~'){
bool f=true;int C=0;
for(int j=2;j<str.size()-2;j++)
{
C++;
if(C%2==0&&str[j]!='=')f=false;
if(C%2==1&&str[j]!='Q')f=false;
}
if(C%2!=0||C==0)f=false;
if(f==true)cout<<"B"<<endl;
else cout<<"NA"<<endl;
}
else cout<<"NA"<<endl;
}
else cout<<"NA"<<endl;
}
return 0;
}
|
#include<iostream>
using namespace std;
int n;
string str;
bool check_A(string t){
int cnt=0,i=0,cnt2=0;
while(t[i]=='='){cnt++;i++;}
if(t[i]!='#')return false;
if(cnt==0)return false;
if((int)t.size()==i)return false;
i++;
while(t[i]=='='){cnt2++;i++;}
if(cnt!=cnt2)return false;
if((int)t.size()!=i+1)return false;
if(t[i]!='~')return false;
return true;
}
bool check_B(string t){
int i=0,cnt=0;
while(i+1<(int)t.size()&&t[i]=='Q'&&t[i+1]=='='){
i+=2;
cnt++;
}
if(cnt==0)return false;
if(i+2!=(int)t.size())return false;
if(t[i]=='~'&&t[i+1]=='~')return true;
return false;
}
int main(){
cin>>n;
while(n--){
cin>>str;
if(str[0]=='>'&&str[1]=='\''){
if(check_A(str.substr(2))){
cout<<'A'<<endl;
}else{
cout<<"NA"<<endl;
}
}else if(str[0]=='>'&&str[1]=='^'){
if(check_B(str.substr(2))){
cout<<'B'<<endl;
}else{
cout<<"NA"<<endl;
}
}else{
cout<<"NA"<<endl;
}
}
return 0;
}
|
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
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()
{
int n;
cin >> n;
while(n--)
{
string snk;
cin >> snk;
if(snk.size() < 6 || snk.size() % 2 != 0 || (snk.substr(0, 2) != ">'" && snk.substr(0, 2) != ">^"))
{
cout << "NA" << endl;
}
else if(snk.substr(0, 2) == ">^")
{
if(snk.substr(2, 2) == "Q=" && snk.substr(snk.size() - 2, 2) == "~~")
{
for(int i = 4; i < snk.size() - 2; i += 2)
{
if(snk.substr(i, 2) != "Q=")
{
goto ng;
}
}
cout << "B" << endl;
}
else
{
ng:;
cout << "NA" << endl;
}
}
else
{
if(snk[(snk.size() - 3) / 2 + 2] == '#' && snk[snk.size() - 1] == '~')
{
rep(i, (snk.size() - 3) / 2)
{
if(snk[i + 2] != '=' || snk[i + 3 + (snk.size() - 3) / 2] != '=')
{
goto ng;
}
}
cout << "A" << endl;
}
else
{
cout << "NA" << endl;
}
}
}
}
|
#include <iostream>
#include <string>
using namespace std;
bool isA(const string& str, int indx) {
if(str[indx++] != '>')
return false;
if(str[indx++] != '\'')
return false;
int count0 = 0;
for(; indx < str.size(); indx++) {
if(str[indx] == '=')
count0++;
else
break;
}
if(indx >= str.size())
return false;
if(str[indx++] != '#' || count0 == 0)
return false;
int count1 = 0;
for(; indx < str.size(); indx++) {
if(str[indx] == '=')
count1++;
else
break;
}
if(count0 == count1 && indx + 1 == str.size() && str[indx] == '~')
return true;
return false;
}
bool isB(const string & str, int indx) {
if(str[indx++] != '>')
return false;
if(str[indx++] != '^')
return false;
int count = 0;
for(; indx + 1 < str.size(); indx += 2) {
if(string(str.begin() + indx, str.begin() + indx + 2) == "Q=")
count++;
else
break;
}
if(count > 0 && string(str.begin() + indx, str.begin() + indx + 2) == "~~" && indx + 2 == str.size())
return true;
return false;
}
int main() {
string str;
int n;
cin >> n;
for(int t = 0; t < n; t++) {
int type = 0;
cin >> str;
for(int i = 0; i < str.size(); i++) {
if(str[i] == '>') {
if(isA(str, i)) {
type = 1;
break;
}
else if(isB(str, i)) {
type = 2;
break;
}
}
}
switch(type) {
case 0:
cout << "NA" << endl;
break;
case 1:
cout << "A" << endl;
break;
case 2:
cout << "B" << endl;
break;
}
}
}
|
#include <iostream>
#include <string>
using namespace std;
string repeat(int n, string s) {
string res = "";
for (int i=0; i<n; ++i)
res += s;
return res;
}
int main() {
int N; cin >> N;
for (int i=0; i<N; ++i) {
string snake; cin >> snake;
int len = snake.size();
if (len <= 4) {
cout << "NA" << endl; continue;
}
string body = repeat(len/2 - 2, "=");
string A = ">'" + body + "#" + body + "~";
if (snake == A) {
cout << "A" << endl; continue;
}
body = repeat(len/2 - 2, "Q=");
string B = ">^" + body + "~~";
if (snake == B) {
cout << "B" << endl; continue;
}
cout << "NA" << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main(){
int n;
cin >> n;
while(n--){
string snake;
cin >> snake;
string s = snake.substr(0,2);
if(s != ">^" && s != ">\'"){
puts("NA");
continue;
}
if(s == ">\'"){
int a = 0;
int p = 2;
bool flg = true;
int len = (int)snake.size();
for(int i = 2 ; i < len ; i++,p++){
if(snake[i] == '#') break;
else if(snake[i] == '=') a++;
else{
flg = false;
break;
}
}
if(!flg){
puts("NA");
continue;
}
int b = 0,q = p + 1;
for(int i = q ; i < len ; i++,p++){
if(snake[i] == '~') break;
else if(snake[i] == '=') b++;
else{
flg = false;
break;
}
}
if(!flg || a == 0 || b == 0 || a != b){
puts("NA");
continue;
}
if(a == b && snake[len-1] == '~'){
puts("A");
}else{
puts("NA");
}
}else{
bool ok = true;
int p = 0;
string ss = "";
int len = (int)snake.size();
if(len < 6 || len % 2){
puts("NA");
continue;
}
for(int i = 2 ; i < len-2 ; i++,p++){
ss += snake[i];
if(p == 1){
p = -1;
if(ss != "Q="){
ok = false;
break;
}
ss = "";
}
}
if(snake[len-2] == '~' && snake[len-1] == '~' && ok){
puts("B");
}else{
puts("NA");
}
}
}
return 0;
}
|
#include <stdio.h>
int main(void){
int t,n;
int i;
for(i=0;i<4;i++){
scanf("%d %d",&t,&n);
if(t==1){
printf("%d\n",6000*n);
}
if(t==2){
printf("%d\n",4000*n);
}
if(t==3){
printf("%d\n",3000*n);
}
if(t==4){
printf("%d\n",2000*n);
}
}
return 0;
}
|
#include<iostream>
using namespace std;
int t[]={0,6000,4000,3000,2000},a,b;
int main(){
while(cin>>a>>b){
cout<<t[a]*b<<endl;
}
return 0;
}
|
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
for (int h = 1; h <= 4;h++){
int t, n, p;
cin >> t >> n;
switch (t){
case 1: p = 6000; break;
case 2: p = 4000; break;
case 3: p = 3000; break;
case 4: p = 2000; break;
}
cout << p*n << endl;
}
}
|
#include<iostream>
using namespace std;
int main(){
int kingaku[] = {6000, 4000, 3000, 2000};
//????????????
for (int i = 0; i < 4; i++) {
int t,n;
cin >> t >> n;
cout << kingaku[t-1] * n << endl;
}
return 0;
}
|
#include <cstdio>
int main() {
int t,n;
for(int i=0;i<4;i++) {
scanf("%d %d",&t,&n);
int sale;
if(t==1) sale=6000*n;
if(t==2) sale=4000*n;
if(t==3) sale=3000*n;
if(t==4) sale=2000*n;
printf("%d\n",sale);
}
}
|
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
int lis[5]={0,6000,4000,3000,2000};
for(int i=0;i<4;i++){
int a,b;
scanf("%d %d",&a,&b);
printf("%d\n",lis[a]*b);
}
return 0;
}
|
#include <stdio.h>
int main(void){
int a;
int t,n;
int i;
for(i=0;i<4;i++){
scanf("%d %d",&t,&n);
if(t==1)t=6000;
if(t==2)t=4000;
if(t==3)t=3000;
if(t==4)t=2000;
a=t*n;
printf("%d\n",a);
}
return 0;
}
|
#include<iostream>
using namespace std;
int main()
{
for(int i=0 ; i<4 ; ++i){
int t,n;
cin >> t >> n;
if(t==1){
cout << 6000*n << endl;
}else if(t==2){
cout << 4000*n << endl;
}else if(t==3){
cout << 3000*n << endl;
}else{
cout << 2000*n << endl;
}
}
return 0;
}
|
#include<cstdio>
int p[4]={6000,4000,3000,2000};
int main(void){
int t,n;
for(int i=0;i<4;i++){
scanf("%d%d",&t,&n);
printf("%d\n",p[t-1]*n);
}
return 0;
}
|
#include<cstdio>
int main(){
int t,n,data[4] = {6000,4000,3000,2000};
for(int i=0;i<4;i++){
scanf("%d %d",&t,&n);
printf("%d\n",data[t-1]*n);
}
return 0;
}
|
#include <iostream>
using namespace std;
int main()
{
int t[5] = {0, 6000, 4000, 3000, 2000};
for (int i = 0; i < 4; i++){
int n, a;
cin >> a >> n;
cout << t[a] * n << endl;
}
return 0;
}
|
#include<stdio.h>
int main() {
int i;
int n;
int prices[] = {6000, 4000, 3000, 2000};
for (i=0; i<4; i++) {
int ind;
unsigned long long int times;
scanf("%d %llu", &ind, ×);
printf("%llu\n", prices[ind-1] * times);
}
}
|
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int a,b;
for(int i=0;i<4;i++){
cin>>a>>b;
if(a==1)cout<<b*6000<<endl;
if(a==2)cout<<b*4000<<endl;
if(a==3)cout<<b*3000<<endl;
if(a==4)cout<<b*2000<<endl;
}return 0;
}
|
#include<iostream>
using namespace std;
int main(){
int t, n;
int p[4] = {6000, 4000, 3000, 2000};
for(int i = 0; i < 4; i++){
cin >> t >> n;
cout << p[t-1]*n << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
int table[] = { 0, 6000, 4000, 3000, 2000 };
for ( int i = 0; i < 4; i++ ) {
int t, n;
cin >> t >> n;
cout << table[t] * n << endl;
}
return ( 0 );
}
|
#include <iostream>
using namespace std;
int main()
{
int t, n;
int sales;
int price[] = { 6000, 4000, 3000, 2000 };
for (int i = 0; i < 4; i++) {
cin >> t >> n;
sales = price[t - 1] * n;
cout << sales << endl;
}
}
|
#include<iostream>
using namespace std;
int main(){
for(int i=0;i<4;i++){
int a,b;
cin>>a>>b;
if(a==1){
cout<<b*6000<<endl;
}
if(a==2){
cout<<b*4000<<endl;
}
if(a==3){
cout<<b*3000<<endl;
}
if(a==4){
cout<<b*2000<<endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(void){
int p[4] = {6000,4000,3000,2000};
int t,n;
for(int i = 0 ; i < 4 ; i++){
cin >> t >> n;
cout << p[t-1]*n <<endl;
}
return 0;
}
|
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int a[4] = {6000, 4000, 3000, 2000}, b, c;
for (int i = 0; i < 4; i++){
scanf("%d%d", &b, &c);
printf("%d\n", a[b-1]*c);
}
return 0;
}
|
#include <iostream>
using namespace std;
int main()
{
int price[] = {6000, 4000, 3000, 2000};
for (int i=0; i<4; i++)
{
int t, n;
cin>>t>>n;
cout<<price[t-1]*n<<endl;
}
}
|
#include<iostream>
using namespace std;
int main(){
int a, b;
for(int i=0;i<4;i++){
cin>>a>>b;
if(a == 1) cout<<6000 * b<<endl;
if(a == 2) cout<<4000 * b<<endl;
if(a == 3) cout<<3000 * b<<endl;
if(a == 4) cout<<2000 * b<<endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int price[4] = {6000, 4000, 3000, 2000};
int main()
{
int t, n;
for (int i = 0; i < 4; i++) {
cin >> t >> n;
cout << price[t - 1] * n << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int ticket[4] = {6000, 4000, 3000, 2000};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
for(int i = 0; i < 4; ++i){
int t, n;
cin >> t >> n;
--t;
cout << ticket[t] * n << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main()
{
int P[4] = { 6000, 4000, 3000, 2000 };
int t[4], n[4];
for (int i = 0; i < 4; i++)
{
cin >> t[i] >> n[i];
}
for (int i = 0; i < 4; i++)
{
cout << P[t[i] - 1] * n[i] << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int v[] = {6000, 4000, 3000, 2000};
int main() {
for (int i = 0; i < 4; i++) {
int t, n;
cin >> t >> n;
cout << n * v[t - 1] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int T[] = {-1, 6000, 4000, 3000, 2000};
int main()
{
for (int i = 0; i < 4; i++){
int t, n;
cin >> t >> n;
cout << T[t] * n << endl;
}
return 0;
}
|
#include<iostream>
using namespace std;
int main(){
int d[] = {6000,4000,3000,2000};
int m,n;
for(int i=0;i<4;i++){
cin >> m >> n;
cout << d[m-1]*n << endl;
}
}
|
#include<iostream>
using namespace std;
int s[5] = { 0,6000,4000,3000,2000 };
int a, b;
int main() {
for (int i = 0; i < 4; i++) {
cin >> a >> b;
cout << s[a] * b << endl;
}
}
|
#include<bits/stdc++.h>
using namespace std;
int main(void){
int a,b;
int sum;
int i;
for(i=0;i<4;i++){
cin>>a>>b;
if(a==1){
cout<<b*6000<<endl;
}
else if(a==2){
cout<<b*4000<<endl;
}
else if(a==3){
cout<<b*3000<<endl;
}
else{
cout<<b*2000<<endl;
}
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
const int MoneyTable[] = { 0,6000,4000,3000,2000 };
int main() {
int t, n;
for (int i = 0; i < 4; ++i) {
cin >> t >> n;
cout << (n*MoneyTable[t]) << endl;
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
for(int i=0;i<4;i++){
cin >> a >> b;
if(a == 1) cout << 6000*b << endl;
if(a == 2) cout << 4000*b << endl;
if(a == 3) cout << 3000*b << endl;
if(a == 4) cout << 2000*b << endl;
}
return (0);
}
|
#include<iostream>
using namespace std;
int main(){
int kane[] = {0,6000,4000,3000,2000};
for(int i = 0; i < 4; i++){
int t,n,sum = 0;
cin >> t >> n;
sum += kane[t] * n;
cout << sum << endl;
}
return 0;
}
|
#include<stdio.h>
int main(void){
int t,n,a[]={6000,4000,3000,2000},i,x[10];
for(i=0;i<4;i++){
scanf("%d%d",&t,&n);
x[i]=a[t-1]*n;
}
for(i=0;i<4;i++) printf("%d\n",x[i]);
return 0;
}
|
#include<cstdio>
using namespace std;
int main(void)
{
int nedan[5]={0,6000,4000,3000,2000};
int t,n;
int kin,i;
for(i=0;i<4;i++) {
scanf("%d %d",&t,&n);
kin=nedan[t]*n;
printf("%d\n",kin);
}
return 0;
}
|
#include<iostream>
using namespace std;
int main()
{
int a[4], b, c, n = 4;
a[0] = 6000;
a[1] = 4000;
a[2] = 3000;
a[3] = 2000;
while( n-- )
{
cin >> b >> c;
cout << a[b-1] * c << endl;
}
return 0;
}
|
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
int main() {
int k[] = { 6000,4000,3000,2000 };
rep(i, 4) {
int a, b; cin >> a >> b;
cout << k[--a] * b << endl;
}
}
|
#include<iostream>
using namespace std;
int main(){
int cla,yen;
for(int i=0;i<4;i++){
cin>>cla>>yen;
if(cla==1){
cout<<6000*yen<<endl;
}else if(cla==2){
cout<<4000*yen<<endl;
}else if(cla==3){
cout<<3000*yen<<endl;
}else if(cla==4){
cout<<2000*yen<<endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int tt[]={0,6000,4000,3000,2000};
int main(){
int t,n;
while(cin >> t >> n){
cout << tt[t]*n << endl;
}
}
|
#include<stdio.h>
int main(void)
{
int a,b,n,i;
for(i=0;i<4;i++){
scanf("%d %d2",&a,&b);
if(a==1) n=b*6000;
if(a==2) n=b*4000;
if(a==3) n=b*3000;
if(a==4) n=b*2000;
printf("%d\n",n);
}
return 0;
}
|
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int d[4]={0};
int r[4]={6000,4000,3000,2000};
for(int i=0;i<4;i++){
int a,b;
cin>>a>>b;
d[a-1]=b;
cout<<d[a-1]*r[a-1]<<endl;
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int type, num;
int price[4] = {6000, 4000, 3000, 2000};
while(scanf("%d %d\n", &type, &num) == 2) {
printf("%d\n", price[type-1]*num);
};
}
|
#include<stdio.h>
int main()
{
int S=6000,A=4000,B=3000,C=2000,a,b,i;
for(i=0;i<4;i++){
scanf("%d %d",&a,&b);
if(a==1){
S=S*b;
printf("%d\n",S);
}else if(a==2){
A=A*b;
printf("%d\n",A);
}else if(a==3){
B=B*b;
printf("%d\n",B);
}else if(a==4){
C=C*b;
printf("%d\n",C);
}
}
return(0);
}
|
#include <cstdio>
int a[4] = {6000, 4000, 3000, 2000};
int main(){
for(int i = 0; i < 4; i++){
int t, n; scanf("%d%d", &t, &n);
t--;
printf("%d\n", a[t]*n);
}
}
|
#include <iostream>
using namespace std;
int main(void){
// Your code here!
int e,y;
for(int a=1;a<=4;a++){
cin>>e>>y;
if(e==1){cout<<6000*y<<endl;}
else if(e==2){cout<<4000*y<<endl;}
else if(e==3){cout<<3000*y<<endl;}
else if(e==4){cout<<2000*y<<endl;}
}
}
|
#include <cstdio>
using namespace std;
int main(void){
int c[] = {0, 6000, 4000, 3000, 2000};
int t, p;
for (int i = 0; i < 4; i++) {
scanf("%d %d", &t, &p);
printf("%d\n", c[t]*p);
}
return 0;
}
|
#include<bits/stdc++.h>
using namespace std;
int main(){
int ans[10]={0},mm[5]={0,6000,4000,3000,2000};
for(int i=0;i<4;i++){
int t,n;
cin>>t>>n;
ans[i]=mm[t]*n;
}
for(int i=0;i<4;i++){
cout<<ans[i]<<endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main (){
int i,a,b,x;
for( i = 1; i <= 4; i++ ){
cin >> a >> b;
if( a==1 ) x=b*6000;
else if( a==2 ) x=b*4000;
else if( a==3 ) x=b*3000;
else if( a==4 ) x=b*2000;
cout << x <<endl;
}
return 0;
}
|
#include <cstdio>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
int p[]={6000,4000,3000,2000};
rep(_,4){
int a,b; scanf("%d%d",&a,&b);
printf("%d\n",p[a-1]*b);
}
return 0;
}
|
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int a,b;
int ticket[4] = {6000,4000,3000,2000};
for(int i=0;i<4;i++){
cin >> a >> b;
cout << ticket[a-1]*b << endl;
}
return 0;
}
|
#include <iostream>
int main(){
int a,b;
for(int i=0;i<4;++i){
std::cin>>a>>b;
int m=0;
if(a==1)m=6000;
else if(a==2)m=4000;
else if(a==3)m=3000;
else m=2000;
std::cout<<b*m<<std::endl;
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.