text
stringlengths
49
983k
#include <iostream> using namespace std; int main(){ int n,full=100000; cin>>n; for(int i=0;i<n;i++){ full*=1.05; if(full%1000!=0){ full +=1000-(full%1000); } } cout<<full<<endl; }
#include <iostream> using namespace std; int main(){ int a=100000,n; cin>>n; for(int i=0;i<n;i++){ if((a*21/20)%1000==0)a=a*21/20; else a=((a*21/20)/1000)*1000+1000; } cout<<a<<endl; return 0; }
#include <iostream> using namespace std; int main(){ int n,cur = 100000; cin >> n; for(int i=0;i<n;i++){ cur *= 1.05; if(cur%1000){ cur += 1000-cur%1000; } } cout << cur << endl; }
#include<iostream> using namespace std; int main(){ int n,a = 100000; cin >>n; while(n--){ a = (int)((double)a*1.05); if(a%1000) a = (a/1000+1)*1000; } cout <<a<<endl; return 0; }
#include<iostream> using namespace std; int main(){ int a=100000,n; cin>>n; for(int i=0;i<n;i++){ a=a*21/20; if(a%1000>0){ a=a/1000; a=a+1; a=a*1000; } } cout<<a<<endl; }
#include <iostream> using namespace std; int main(){ int debt = 100000, n; cin >> n; for(int i = 0; i < n; ++i){ debt = ((int)(debt * 1.05) + 999) / 1000 * 1000; } cout << debt << endl; return 0; }
#include <iostream> using namespace std; int main(){int n,x;x = 100000;cin >> n;for (int i=0;i<n;i++) {x = 1.05*x;if (x%1000!=0) {x = x +(1000-x%1000);}}cout << x << endl;return 0;}
#include<iostream> using namespace std; int main(){ int money = 100000,n; cin >>n; while(n--){ money = (int)(money*1.05); if(money%1000){money = (money/1000+1)*1000;} } cout <<money<<endl; return 0; }
#include<iostream> using namespace std; int main(){ int n; cin >>n; int a = 100000; for (int i= 0; i<n; i++){ a = a*1.05; if(a%1000 >0) a= a-a%1000+ 1000; } cout << a <<endl; }
#include <iostream> using namespace std; int main() { int n, a = 100000; cin >> n; while(n--) { a *= 1.05; if(a % 1000 > 0) { a += 1000; a -= (a % 1000); } } cout << a << endl; return 0; }
#include<iostream> using namespace std; int main(){ int a,b,rone=100000; cin>>a; for(int i=0;i<a;i++){ rone *=1.05; b = rone % 1000; rone -= b; if(b>0) rone += 1000; } cout<<rone<<endl; }
#include<iostream> int main(){ int n,a=100000,b; std::cin>>n; for(b=0;b<n;b++){ a*=1.05; if(a%1000!=0){ a=a-(a%1000)+1000; } } std::cout<< a <<std::endl; return 0; }
#include<stdio.h> int main(void) { int n,i,w=100000; scanf("%d",&n); for(i=0;i<n;i++){ w=w*1.05; if(w%1000>0){ w=w-(w%1000)+1000; } } printf("%d\n",w); return 0; }
#include<iostream> #include<cmath> int main(){ int n,sum=100000; std::cin>>n; for(int i=0;i<n;i++){ sum*=1.05; if(sum%1000!=0){ sum+=1000-(sum%1000); } } std::cout<<sum<<std::endl; return 0; }
#include<iostream> using namespace std; int main(){ int n,d=100000; cin>>n; for(int i=0;i<n;i++){ d*=1.05; if(d%1000!=0)d=(d/1000)*1000+1000; } cout <<d<<endl; }
#include<iostream> using namespace std; int main(){ int n,s=100000; cin>>n; for(int i=1;i<=n;i++){ s+=s*0.05; if(s%1000!=0) s=s-s%1000+1000; } cout<<s<<endl; }
#include<iostream> using namespace std; int main(){ int n, ans = 100000; cin >> n; for(int i = 0; i < n; i++){ ans *= 1.05; if(ans % 1000 != 0) ans += (1000 - (ans % 1000)); } cout << ans << endl; }
#include<iostream> #include<cmath> using namespace std; int main(){ int n; cin >> n; double debt = 100; for(int i = 0; i < n; i++){ debt = ceil(debt*1.05); } cout << (long long)debt * 1000 << endl; }
#include<stdio.h> #include<math.h> int main(){ int a; scanf("%d",&a); int b=100000; for(int i=0;i<a;i++){ b*=1.05; if(b%1000!=0)b=(b/1000+1)*1000; } printf("%d\n",b); }
#include <iostream> using namespace std; int main() { int i,n,Debt=100000; cin>>n; for(;n>0;--n){ i=Debt*0.05; if(i%1000!=0) i=1000+(i/1000)*1000; Debt+=i; } cout<<Debt<<endl; return 0; }
#include <iostream> using namespace std; int main(){ int n, a = 100000; cin >> n; for(int i = 0;i < n;i++){ a *= 1.05; if(a%1000 != 0)a += 1000 - a%1000; } cout << a << endl; return 0; }
#include <iostream> using namespace std; int main() { int d = 100000; int n; cin >> n; for (int i = 0; i < n; i++) { d *= 1.05; if (d % 1000 != 0) d += (1000 - (d % 1000)); } cout << d << endl; return 0; }
#include<iostream> using namespace std; int main(){ int n,ans = 100000; cin >>n; while(n--){ ans = (int)((double)ans*1.05); if(ans%1000>0) ans = (ans/1000+1)*1000; } cout <<ans<<endl; return 0; }
#include<iostream> using namespace std; int main(){ int a,b,c; int i,n; cin>>n; a=100000; for(i=0;i<n;i++){ b=a/20+a; if(b%1000!=0)b+=1000; b/=1000; b*=1000; a=b; } cout<<a<<endl; return 0; }
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { int a, b = 100000; scanf("%d", &a); for (int i = 0; i<a; i++) { b *= 1.05; if (b % 1000 != 0)b = (b/1000+1)*1000; } printf("%d\n", b); }
#include <iostream> int main (void){ int week,res=100,i; std::cin >> week; for(i=0; i < week; i++){ res += (int)(0.05 * res + 0.99 ); } std::cout << res*1000 << std::endl; return 0; }
#include<iostream> using namespace std; int main(){ int moto=100,syuu; cin>>syuu; for(int abc=0;abc<syuu;abc++){ if(moto%20!=0){ moto=moto*1.05+1; }else{ moto*=1.05; } } cout<<moto*1000<<endl; return 0; }
#include<stdio.h> int main(void) { int n,s,ss,i; scanf("%d",&n); s=100000; for(i=0;i<n;i++){ ss=s*0.05; s+=ss; if(s%1000!=0){ s=s/1000; s=(s+1)*1000; } } printf("%d\n",s); return 0; }
#include<iostream> #include<cmath> using namespace std; int main(){ long i,n,t=100; cin>>n; for(i=0;i<n;i++)t=ceil(t*1.05); cout<<t*1000<<endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; long a = 100000; cin >> n; for(int i = 0; i < n; i++){ a *= 1.05; if(a % 1000 > 0) a = a + 1000 - a % 1000; } cout << a << endl; }
#include <iostream> using namespace std; int main(){ int N; cin>>N; int res=100000; for(int i=1;i<=N;i++){ res=res*105/100; res=(res+999)/1000*1000; } cout<<res<<endl; return 0; }
#include<iostream> using namespace std; int main(){ int n,mon=100000; cin>>n; for(int i=0;i<n;i++){ mon=mon*1.05; mon=(mon+999)-(int(mon+999)%1000); } cout<<mon<<endl; return 0; }
#include <iostream> using namespace std; int main(){ int a=100000,b=0,t; cin>>t; for(int k=0;k<t;k++){ b=a*1.05; b=(b+999)/1000*1000; a=b; } cout<<a<<endl; }
#include <stdio.h> int main(void){ int n; scanf("%d",&n); int coin=100000; for(int m=0;m<n;m++){ coin*=1.05; coin=(coin/1000)*1000+((coin%1000)>0? 1000:0); } printf("%d\n",coin); return 0; }
#include<iostream> using namespace std; int main(){ int n,i,a=100000; cin>> n; for(i=0;i<n;i++){ a=a+(a*0.05); if(a%1000 != 0){ a=a-(a%1000)+1000; } } cout << a << endl; }
#include <iostream> using namespace std; int main() { int week; cin >> week; int debt = 100; while (week--) { debt = ((debt * 105) / 100) + ((debt % 20) > 0 ? 1 : 0); } cout << debt * 1000 << endl; return 0; }
#include <iostream> using namespace std; int main() { int i, n; int money=100000; cin >> n; for(i=1; i<=n; i++){ money *= 1.05; money = (money+999) / 1000 * 1000; } cout << money << endl; return 0; }
#include <iostream> using namespace std; int main() { int n; cin>>n; int dept=100000; for(int i=0;i<n;i++){ dept+=dept/20; if(dept%1000) dept+=1000-dept%1000; } cout<<dept<<endl; return 0; }
#include <iostream> using namespace std; int main() { long m,n=100000; cin>>m; for(int i=0;i<m;i++){ n*=21; n/=20; if(n%1000!=0){ n+=(1000-n%1000); } } cout<<n<<endl; return 0; }
#include <iostream> int main(void) { int n; int m = 100000; std::cin >> n; while (n--) { m *= 1.05; m = (m + 999) / 1000 * 1000; } std::cout << m << std::endl; return 0; }
#include<iostream> using namespace std; int main(){ int n,solve = 100000; cin >>n; while(n--){ solve = solve*1.05; if(solve%1000 > 0) solve = solve/1000*1000+1000; } cout <<solve<<endl; return 0; }
#include <iostream> #include <cmath> using namespace std; int main() { int money=100, week; cin>>week; for(int i=0; i<week; i++) { money = ceil(money*1.05); } cout<<(money*1000)<<endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ double cap = 100000.0; int n; cin >> n; for (int i=0;i<n;i++){ cap *= 1.05; cap /= 1000; cap = ceil(cap); cap *= 1000; } cout << int(cap) << endl; }
#include<iostream> using namespace std; int main(){ int n;cin>>n;int C=100; for(int i=0;i<n;i++){ long double E=C;E*=1.05l; E+=0.999;C=(int)E; } cout<<C*1000<<endl; }
#include<iostream> using namespace std; int main(void){ int debt=100000; int n; cin >> n; for(int i=0; i<n; i++){ debt *= 1.05; if(debt%1000!=0) debt=(debt/1000)*1000+1000; } cout << debt << endl; }
#include <stdio.h> #include <math.h> int main(void){ int l = 100000; float tl = 0.0; int n = 0; scanf("%d", &n); for(int i=0;i<n;i++){ l = (int)(ceilf(l * 1.05f / 1000) * 1000); } printf("%d\n", l); return 0; }
#include<stdio.h> int main(){ int n; int sum=100000; scanf("%d",&n); while(n){ sum*=1.05; if(sum%1000!=0)sum=(sum/1000+1)*1000; n--;} printf("%d\n",sum); return 0;}
#include <iostream> using namespace std; int b=100000; int a; int main(){ cin>>a; for(int i=0;i<a;i++){ b*=1.05; int d=b/1000; if(d*1000<b){ b=d*1000+1000; } } cout<<b<<endl; return 0; }
#include <iostream> using namespace std; int main() { int n; cin >> n; int ans = 100000; while(n--){ ans*=1.05; if(ans%1000) ans=(ans/1000+1) * 1000; } cout << ans << endl; return 0; }
#include<iostream> using namespace std; int main(){ int n,a; a = 100000; cin >> n; for (int i = 0; i < n; i++) { a=a*1.05; a = ((a + 999) / 1000) * 1000; } cout << a << endl; return 0; }
#include<iostream> using namespace std; int main() { int n; cin>>n; int res=100000; for(int i=0;i<n;i++){ res=res*1.05; if(res%1000>0) res+=1000; res-=res%1000; } cout<<res<<endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ans = 100000; while (n--) { ans = ans + ceil(ans * 0.05 / 1000) * 1000; } cout << ans << endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int ans = 100000; for(int i=0; i<n; i++){ ans = (int(ans + ans*0.05 + 999)/1000)*1000; } cout << ans << endl; }
#include<iostream> using namespace std; #define L long long int int main(){ int n,ans=100000; cin>>n; while(n--){ ans*=1.05; ans+=ans%1000==0 ? -ans%1000:1000-ans%1000; } cout<<ans<<endl; return 0; }
#include <iostream> using namespace std; int main() { int n=0; cin>>n; long long c = 100000; for ( int i=0; i<n; i++ ) { c += c/20; c = (c+999)/1000*1000; } cout << c << endl; return 0; }
#include<iostream> using namespace std; int main(){ int n,ans=100000; cin >>n; while(n--){ ans = (int)(ans*1.05); if(ans>(ans/1000)*1000) ans = (ans/1000)*1000+1000; } cout <<ans<<endl; return 0; }
#include <stdio.h> int main(void){ int n,m=100000; scanf("%d",&n); while(n--)m+=m*.05,m+=(m%1000?1000-m%1000:0); printf("%d\n",m); return 0; }
#include<iostream> using namespace std; int main(){ int a=100000,b,n; cin>>n; for(int i=0;i<n;i++){ a=a*1.05; b=a%1000; if(b!=0)a=a-b+1000; } cout<<a<<endl; return 0; }
#include<iostream> using namespace std; int main() { int money = 100; int n; cin >> n; while(n--) { money += money % 20 ? money / 20 + 1 : money / 20; } cout << money << "000" << endl; return 0; }
#include<iostream> int main(){ int n; std::cin>>n; int s=100000; for(int i=0;i<n;i++){ s*=1.05; if(s%1000!=0)s/=1000,s+=1; else s/=1000; s*=1000; } std::cout<<s<<std::endl; return 0; }
#include<bits/stdc++.h> using namespace std; int main(){ int a=100000; int b; cin >> b; int c=0; while (c<b){ a=a+a*0.05; c=c+1; a=((a+999)/1000)*1000; } printf("%d\n",a); }
#include <bits/stdc++.h> //#include <iostream> //#include <Windows.h> using namespace std; int main(){ int n; int a=100000; cin>>n; while (n--){ a*=1.05; int l=a%1000; if(l>0)a+=1000-l; } cout<<a<<endl; return 0; }
#include <iostream> using namespace std; int n, m = 100000; int main() { cin >> n; for (int i = 0; i < n; i++) m += (m / 20 + 999) / 1000 * 1000; cout << m << endl; return 0; }
#include <iostream> using namespace std; int main(void){ int a; cin>>a; int i; int b=100000; for(i = 0; i < a; i++){ b=(b*1.05); b=(((b+999)/1000)*1000); } cout<<b<<endl; }
#include <iostream> #include <math.h> using namespace std; int main(){ int money=100000; int i,n; cin >> n; for(i=0;i<n;i++){ money*=1.05; if(money%1000!=0){ money+=1000-(money%1000); } } cout << money << endl; }
#include<bits/stdc++.h> using namespace std; int main(void){ int n; int sum; int i; cin>>n; sum=100000; for(i=1;i<=n;i++){ sum*=1.05; if(sum%1000) sum=sum-sum%1000+1000; } cout<<sum<<endl; return 0; }
#include <stdio.h> int main() { int i,n,m=100000; scanf("%d",&n); for(i=0;i<n;i++) { m *= 1.05; if(m%1000) m+=1000; m/=1000; m*=1000; } printf("%d\n",m); }
#include<iostream> #include<string> using namespace std; int main(){ int m; int s=100000; cin>>m; for(int i=0;i<m;i++){ s = s*1.05; if(s%1000!=0) s = ((s/1000)+1)*1000; } cout<<s<<endl; return 0; }
#include<iostream> using namespace std; int main(void) { int n,ans; cin>>n; ans=10*10000; for(int i=1;i<=n;i++){ ans=ans*1.05; if(ans%1000!=0){ ans=ans-(ans%1000)+1000; } } cout<<ans<<endl; }
#include <iostream> #include <cmath> using namespace std; int main() { int n, debt = 100; cin >> n; while(n-- > 0) debt = ceil(debt * 1.05); cout << debt * 1000 << endl; }
#include <iostream> using namespace std; int main() { int n, ans; cin >> n; ans = 100000; for(int i=0; i<n; i++) { ans *= 1.05; if(ans%1000 != 0) ans = (ans/1000+1)*1000; } cout << ans << endl; return 0; }
#include <stdio.h> int main(){ int b=100000,n; scanf("%d",&n); for(int i = 0;i<n;i++){ b*=1.05; if(b%1000!=0)b=(b/1000+1)*1000; } printf("%d\n",b); return 0; }
#include <iostream> using namespace std; int main(){ int n, t = 100000; cin >> n; for( int i = 0; i < n; ++i){ t = 1.05 * t; t = (t/1000)*1000 + ((t % 1000 != 0) ? 1000 : 0); } cout << t << "\n"; return 0; }
#include<iostream> using namespace std; int main(){ int n,debt=100000; cin>>n; while(n--){ debt=debt*1.05; debt+=999; debt/=1000; debt*=1000; } cout<<debt<<endl; return 0; }
#include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ int a=100000,n; cin>>n; for(int i=1;i<=n;++i){ a*=1.05; if(a%1000>0){ a/=1000; a++; a*=1000; } } cout<<a<<endl; }
#include <cstdio> #include <cmath> using namespace std; int main() { int n, a = 100000; scanf("%d", &n); while (n--) { a += a * 5 / 100; a = (int)ceil(a / 1000.0) * 1000; } printf("%d\n", a); }
#include<stdio.h> int main(void) { int n,i,j,x; scanf("%d",&n); i=100000; for(j=0;j<n;j++){ i=i*5/100+i; x=i%1000; if(x!=0){ x=1000-x; i=i+x; } } printf("%d\n",i); return 0; }
#include<stdio.h> int main(){ int C = 100000,n; scanf("%d",&n); for(int i = 0;i < n;i++){ C = (C*21)/20; if(C%1000 > 0) C += 1000-C%1000; } printf("%d\n",C); return 0; }
#include<iostream> int main(){int n,s=100000,i;std::cin>>n;for(i=0;i<n;i++)s*=1.05,s+=(1000-(s%1000==0?1000:s%1000));std::cout<<s<<"\n";}
#include<iostream> using namespace std; int main(){ int n,sum = 100000; cin >>n; while(n--){ sum = (int)(sum*1.05); if(sum%1000){sum = (sum/1000)*1000+1000;} } cout <<sum<<endl; return 0; }
#include <iostream> using namespace std; int main(){ int week, yen=100000, hasuu; cin>>week; while(week--){ yen = yen*1.05; if(hasuu=yen%1000){ yen += 1000-hasuu; } } cout << yen <<endl; return 0; }
#include<iostream> #include<stdio.h> int main(){ int n,i,a=100000,b; std::cin>>n; for(i=0;i<n;i++){ a=a*1.05; if(a%1000!=0){ b=a%1000; b=1000-b; a=a+b; } } std::cout<<a<<std::endl; return 0; }
#include<iostream> #include<regex> #include<string> int main() { int n; std::cin >> n; std::cin.ignore(); while( n-- ) { std::string s; std::getline( std::cin, s ); std::smatch m; if( std::regex_match( s, m, std::regex( ">\'(=+)#(=+)~" ) ) && m[1].length() == m[2].length() ) std::cout << 'A' << std::endl; else if( std::regex_match( s, std::regex( ">^(Q=)+~~" ) ) ) std::cout << 'B' << std::endl; else std::cout << "NA" << std::endl; } return 0; }
#include <bits/stdc++.h> #define rep(i,l,n) for(int i=l;i<n;i++) #define all(a) a.begin(),a.end() #define o(a) cout<<a<<endl #define int long long using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pii; signed main(){ int n; cin>>n; rep(i,0,n){ string s; cin>>s; int ans=0; int sz=s.size(); if(sz<6){ ans=-1; }else if(s[0]=='>'&&s[1]=='\''&&s[sz-1]=='~'&&sz%2==0&&s[sz/2]=='#'){ rep(i,2,sz-1){ if(i!=sz/2&&s[i]!='='){ ans=-1; break; } if(i==sz-2) ans=1; } }else if(s[0]=='>'&&s[1]=='^'&&s[sz-2]=='~'&&s[sz-1]=='~'&&sz%2==0){ rep(i,2,sz-2){ if(i%2==0&&s[i]!='Q'){ ans=-1; break; }if(i%2&&s[i]!='='){ ans=-1; break; } if(i==sz-3) ans=2; } }else{ ans=-1; } if(ans==-1) o("NA"); else if(ans==1) o("A"); else if(ans==2) o("B"); } }
#include<iostream> using namespace std; string in; int isA(){ if(in.length() < 5) return 0; if(in[0] != '>') return 0; if(in[1] != '\'') return 0; if(!(in[in.length()-1] == '~' && in[in.length()-2] == '=')) return 0; int data[2] = {0,0}; int status = 0; for(int i = 2; i < in.length()-1; i++){ if(in[i] == '#') status = 1; if(in[i] == '=') data[status]++; if(in[i] != '#' && in[i] != '=') return 0; } if(data[0] && data[0] == data[1]) return 1; return 0; } int isB(){ if(in.length() < 5) return 0; if(in[0] != '>') return 0; if(in[1] != '^') return 0; if(!(in[in.length()-1] == '~' && in[in.length()-2] == '~')) return 0; for(int i = 2; i < in.length()-2; i+=2){ if(!(in[i] == 'Q' && in[i+1] == '=')) return 0; } return 1; } int main(){ int num; cin >> num; for(int i = 0; i < num; i++){ cin >> in; if(isA()) cout << "A" << endl; else if(isB()) cout << "B" << endl; else cout << "NA" << endl; } return 0; }
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; int a; bool check(const string st,const int isa) { a = 0; if (isa) { if (st[a] != '>')return false; a++; if (st[a] != '\'')return false; a++; int num = 0; while (st[a] == '=') { num++; a++; } if (!num)return false; if (st[a] != '#')return false; a++; int num2 = 0; while (st[a] == '=') { num2++; a++; } if (num != num2)return false; if (st[a] != '~')return false; a++; if (st[a] != ' ')return false; return true; } else { if (st[a] != '>')return false; a++; if (st[a] != '^')return false; a++; int num = 0; while (1) { if (st[a] == 'Q') { num++; a++; if (st[a] != '=') { return false; } else { a++; } } else { break; } } if (!num)return false; if (st[a] != '~')return false; a++; if (st[a] != '~')return false; a++; if (st[a] != ' ')return false; return true; } } int main() { int N; cin >> N; while (N--) { string st; cin >> st; for (int i = 0; i < 100; ++i) { st.push_back(' '); } if (check(st, true)) { cout << "A" << endl; } else if (check(st, false)) { cout << "B" << endl; } else { cout << "NA" << endl; } } return 0; }
#include <iostream> #include <string> #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int main() { int n; cin >> n; rep(i,n) { string s; cin >> s; if(s[0] == '>' && s[1] == '\'' && s[2] == '=') { int i = 2; int cnt = 0; while(s[i] == '=') { i++; cnt++; } if(s[i] == '#' && i < s.size()) { i++; while(s[i] == '=') { if(i == s.size()-1) break; i++; cnt--; } } if(cnt == 0 && s[i] == '~') cout << "A" << endl; else cout << "NA" << endl; } else if(s[0] == '>' && s[1] == '^' && s[2] == 'Q') { int i = 2; int cnt = 0; bool end = false; while(i+1 < s.size()) { if(s[i] == 'Q' && s[i+1] == '=') { i += 2; } else if(s[i] == '~' && s[i+1] == '~') { end = true; cout << "B" << endl; i += 2; } else { break; } } if (!end) cout << "NA" << endl; } else { cout << "NA" << endl; } } return 0; }
#include "bits/stdc++.h" using namespace std; typedef vector<int> vi; typedef pair<int,int> pii; typedef long long ll; #define dump(x) cerr << #x << " = " << (x) << endl #define rep(i,n) for(int i=0;i<(n);i++) #define all(a) (a).begin(),(a).end() #define pb push_back string solve(string s){ if(s.substr(0,2)==">'"){ int eq=0; for(int i=2;i<s.size();i++){ if(s[i]!='=')break; else{ eq++; } } if(eq==0)return "NA"; if( s[ (2 + eq -1) +1 ] != '#')return "NA"; if( s.substr( ((2+eq-1)+1) +1 ,eq ) != s.substr( 2,eq ) )return "NA"; if( 2+eq+1+eq+1 == s.size() && s[ (2+eq+1+eq+1) -1 ]=='~')return "A"; }else if(s.substr(0,2)==">^"){ int c=2; while( s[c]=='Q' && s[c+1]=='=' ){ c+=2; } if(c==2)return "NA"; if( c+1==s.size()-1 && s[c]=='~' && s[c+1]=='~')return "B"; else return "NA"; }else return "NA"; return "NA"; } int main(){ int n; cin>>n; rep(i,n){ string s; cin>>s; cout<<solve(s)<<endl; } return 0; }
//include //------------------------------------------ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <tuple> 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();} //math //------------------------------------------- template<class T> inline T sqr(T x) {return x*x;} //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; //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 MT make_tuple #define SZ(a) int((a).size()) #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,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); const int DX[] = {0, 1, 0, -1}; const int DY[] = {-1, 0, 1, 0}; //other //-------------------------------------------- #define RANGE(a, c, b) ((a <= b) && (b < c)) //clear memory #define CLR(a) memset((a), 0 ,sizeof(a)) //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; int solve(string snake){ if(snake[0] != '>') return 0; if(snake[1] == '\''){ int i = 2; while(snake[i] == '='){ i++; } if(snake[i] != '#') return 0; int length = i - 2; i++; while(snake[i] == '='){ i++; } int length2 = i -3 - length; if(length2 != length) return 0; if(length > 0 && snake[i] == '~' && i == snake.length() - 1){ return 1; } }else if(snake[1] == '^'){ int i = 2; int length = 0; while(snake[i] =='Q' && snake[i + 1] == '='){ i += 2; length++; } if(length > 0 && snake[i] == '~' && snake[i + 1] == '~' && i + 1 == snake.length() - 1){ return 2; } } return 0; } int main(int argc, char const *argv[]) { int n; cin >> n; REP(i, n){ string snake; cin >> snake; string ans; switch(solve(snake)){ case 0: ans = "NA"; break; case 1: ans = "A"; break; case 2: ans = "B"; break; } cout << ans << endl; } return 0; }
#include <iostream> #include <string> using namespace std; int stateA,stateB; int anum; void inA(char arg){ //cout << stateA << endl; if(stateA == 0){ if(arg == '>'){ stateA = 1; } }else if(stateA == 1){ if(arg == '\''){ stateA = 2; }else{ stateA = -1; } }else if(stateA == 2){ if(arg == '='){ stateA = 3; anum++; }else{ stateA = -1; } }else if(stateA == 3){ if(arg == '='){ anum++; }else if(arg == '#'){ stateA = 4; }else{ stateA = -1; } }else if(stateA == 4){ if(arg == '='){ anum--; }else{ stateA = -1; } if(anum==0){ stateA = 5; } }else if(stateA == 5){ if(arg == '~'){ stateA = 6; }else{ stateA = -1; } }else if(stateA == 6){ stateA = -1; } } void inB(char arg){ if(stateB == 0){ if(arg == '>'){ stateB = 1; }else{ stateB = -1; } }else if(stateB == 1){ if(arg == '^'){ stateB = 2; }else{ stateB = -1; } }else if(stateB == 2){ if(arg == 'Q'){ stateB = 3; }else{ stateB = -1; } }else if(stateB == 3){ if(arg == '='){ stateB = 4; }else{ stateB = -1; } }else if(stateB == 4){ if(arg == 'Q'){ stateB = 5; }else if(arg == '~'){ stateB = 6; }else{ stateB = -1; } }else if(stateB == 5){ if(arg == '='){ stateB = 4; }else{ stateB = -1; } }else if(stateB == 6){ if(arg == '~'){ stateB = 7; }else{ stateB = -1; } }else if(stateB == 7){ stateB = -1; } } int main(){ int n; string str; cin >> n; cin.ignore(); while(n && getline(cin,str)){ stateA=0; stateB=0; anum=0; bool A=false, B=false; int l = str.size(); for(int i=0;i<l;i++){ inA(str[i]); inB(str[i]); } if(stateA == 6){ cout << "A" << endl; }else if(stateB == 7){ cout << "B" << endl; }else{ cout << "NA" << endl; } n--; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i=0; i<n; i++) { string S; cin >> S; if (S.size()<4) { cout << "NA" << endl; continue; } if (S.substr(0, 2)==">'" && S[S.size()-1]=='~') { int mark = -1; for (int j=2; j<S.size()-1; j++) { if (S[j]=='#') mark = j; } bool flag = true; for (int j=2; j<S.size()-1; j++) { if (j==mark) continue; if (S[j]!='=') flag = false; } if (flag && mark!=-1 && mark-2==S.size()-2-mark && mark-2>0) cout << 'A' << endl; else cout << "NA" << endl; } else if (S[0]=='>' && S[1]=='^' && S[S.size()-2]=='~' && S[S.size()-1]=='~') { int idx = 2, cnt = 0; while (true) { if (S[idx]=='Q' && S[idx+1]=='=') { cnt++; idx += 2; } else break; } if (cnt>0 && idx==S.size()-2) cout << 'B' << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } }
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(n); i++) #define REP2(i,x,n) for(int i=x; i<(n); i++) #define ALL(n) begin(n),end(n) struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; int check( string S ) { //A if( S[ 0 ] == '>' && S[ 1 ] == '\'' && S[ S.size() - 1 ] == '~' && S.size() >= 6 ) { S = S.substr( 2, S.size() - 3 ); if( S.find_first_not_of( "#=", 0 ) != string::npos ) return 0; string tmpB = S.substr( 0, S.find('#') ); string tmpA = S.substr( S.find( '#' ) + 1, S.size() - 1 ); return tmpB.size() == tmpA.size() ? 1 : 0; } //B if( S[ 0 ] == '>' && S[ 1 ] == '^' && S[ S.size() - 1 ] == '~' && S[ S.size() - 2 ] == '~' && S.size() >= 6 ) { S = S.substr( 2, S.size() - 4 ); if( S.find_first_not_of( "Q=", 0 ) != string::npos ) return 0; if( S.size() % 2 != 0 ) return 0; for( int i = 0; i < S.size(); i += 2 ) { if( S[ i ] != 'Q' && S[ i + 1 ] != '=' ) return 0; } return 2; } return 0; } int main() { int N; cin >> N; vector<string> res{ "NA", "A", "B" }; string S; while( cin >> S ) { cout << res[ check( S ) ] << endl; } return 0; }
#define _USE_MATH_DEFINES #include <iostream> #include <sstream> #include <cmath> #include <algorithm> #include <queue> #include <stack> #include <limits> #include <map> #include <string> #include <cstring> #include <set> #include <deque> 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; } } }
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <stdio.h> #include <ctype.h> #include <string> #include <iostream> #include <vector> #include <stack> #include <fstream> #include <sstream> #include <queue> #include <exception> #include <cmath> #include <numeric> #include <map> #include <algorithm> #include <bitset> #include <set> #include <functional> #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--) using namespace std; typedef long long int lint; void AOJ0139() { string snake; cin >> snake; if (snake[0] != '>') { cout << "NA" << endl; return; } //A if (snake[1] == '\'') { if (snake[2] != '=') { cout << "NA" << endl; return; } int eq_count = 0; int pos = 2; while (snake[pos] == '=') { eq_count++; pos++; } if (snake[pos] != '#') { cout << "NA" << endl; return; } pos++; FOR(i, pos, pos + eq_count) { if (snake[i] != '=') { cout << "NA" << endl; return; } } pos += eq_count; if (snake.substr(pos) != "~") { cout << "NA" << endl; return; } cout << "A" << endl; return; } //B if (snake[1] == '^') { int Q_count = 0; int pos = 2; if (snake.substr(pos, 2) != "Q=") { cout << "NA" << endl; return; } while (snake.substr(pos, 2) == "Q=") { pos += 2; } if (snake.substr(pos) != "~~") { cout << "NA" << endl; return; } cout << "B" << endl; return; } cout << "NA" << endl; return; } int main() { int n; cin >> n; REP(i, n) AOJ0139(); return 0; }
#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 A = ">'" + repeat((len - 4)/2, "=") + "#" + repeat((len - 4)/2, "=") + "~"; string B = ">^" + repeat((len - 4)/2, "Q=") + "~~"; if (snake == A) { cout << "A" << endl; } else if (snake == B) { cout << "B" << endl; } else { cout << "NA" << endl; } } return 0; }
#include <iostream> using namespace std; int main(){ int n; cin >> n; while(n--){ int i,eq1,eq2; string ret = "NA"; string s; cin >> s; if(s.substr(0,3) == ">'="){ i = 2; eq1 = 0; while(s[i] == '=' && i < s.length() )i++,eq1++; if(s[i] != '#')goto label; i++; eq2 = 0; while(s[i] == '=' && i < s.length() )i++,eq2++; if(i == s.length()-1 && s[i] == '~' && eq1 == eq2) ret = "A"; }else if(s.substr(0,4) == ">^Q="){ for(i=2;i+1<s.length()-2;i+=2){ if(s[i] == 'Q' && s[i+1] == '='){} else goto label; } if(s[s.length()-1] == '~' && s[s.length()-2] == '~' && s[s.length()-3] == '=' && s[s.length()-4] == 'Q') ret = "B"; } label:; cout << ret << endl; } }
#include <iostream> //#include <fstream> #define NA cout << "NA" << endl; goto LABEL using namespace std; int main() { //ifstream fin("in.txt"); int snakeCount; cin >> snakeCount; for(int loopCount = 0; loopCount < snakeCount; loopCount++) { char arr[202]; cin >> arr; int i = 0; if(arr[i]!='>') { NA; } i++; if(arr[i]=='\'') { int equalCount = 0; bool mode = false; for(int j = i+1; j < 202; j++) { if(arr[j]=='=') { if(!mode) { equalCount++; }else { equalCount--; } }else if(arr[j]=='#') { if(!mode && equalCount>0) { mode = !mode; }else { NA; } }else if(arr[j]=='~') { if(arr[j+1]=='\0'&&equalCount==0&&mode) { cout << "A" << endl; goto LABEL; }else { NA; } }else { NA; } } }else if(arr[i]=='^') { int count = 0; for(int j = i+1; j < 202; j++) { if(arr[j]=='Q'&&arr[j+1]=='=') { j++; count++; continue; }else if(arr[j]=='~'&&arr[j+1]=='~'&&arr[j+2]=='\0'&&count>0) { cout<< "B" << endl; goto LABEL; }else { NA; } } }else { NA; } LABEL:; } return 0; }
#include <iostream> #include <string> using namespace std; bool isA( string& s ) { int ptr = 0; if( s.size() < 6 || s[ 0 ] != '>' || s[ 1 ] != '\'' || s[ s.size() - 1 ] != '~' ){ return false; } ptr = 2; while( ptr < s.size() - 1 && s[ ptr ] == '=' ){ ++ptr; } if( s[ ptr ] != '#' ){ return false; } int halfLength = ptr - 2; if( s.size() != 4 + halfLength * 2 ){ return false; } ++ptr; for( int i = 0; i < halfLength; ++i, ++ptr ){ if( s[ ptr ] != '=' ){ return false; } } return true; } bool isB( string& s ) { int ptr = 0; if( s.size() < 6 || s[ 0 ] != '>' || s[ 1 ] != '^' || s[ s.size() - 1 ] != '~' || s[ s.size() - 2 ] != '~' ){ return false; } int restLength = s.size() - 4; if( restLength % 2 > 0 ){ return false; } ptr = 2; while( ptr < restLength + 2 ){ if( s[ ptr ] != 'Q' || s[ ptr + 1 ] != '=' ){ return false; } ptr += 2; } return true; } int main() { int n; while( cin >> n ){ for( int i = 0; i < n; ++i ){ string snake; cin >> snake; string result; if( isA( snake ) ) result = "A"; else if( isB( snake ) ) result = "B"; else result = "NA"; cout << result << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int Tc; cin >> Tc; while(Tc--) { string S; cin >> S; LA: { string s = S; if(s.size() < 6) goto BAD; if(s.substr(0, 3) != ">'=") goto LB; if(s[s.size()-1] != '~') goto BAD; s = s.substr(2); s = s.substr(0,s.size()-1); int pos = -1; int const size = s.size(); int cnt = 0; for(int i=0; i<size; i++) { if(s[i] == '=') cnt++; else if(s[i] == '#') { pos = i; break; } else goto BAD; } if(pos == -1) goto BAD; if(2*cnt+1 != s.size()) goto BAD; for(int i=cnt+1; i<2*cnt+1; i++) { if(s[i] != '=') goto BAD; } cout << "A" << endl; goto EXIT; } LB: { string s = S; if(s.substr(0, 2) != ">^") goto BAD; if(s.substr(s.size()-2) != "~~") goto BAD; s = s.substr(2); s = s.substr(0, s.size()-2); if(s.size() % 2 || s.empty()) goto BAD; int const size = s.size(); for(int i=0; i<size; i+=2) { if(!(s[i] == 'Q' && s[i+1] == '=')) goto BAD; } cout << "B" << endl; goto EXIT; } BAD:; cout << "NA" << endl; EXIT:; } return 0; }
#include <bits/stdc++.h> using namespace std; int main(void){ int n; cin>>n; for (int i=0;i<n;i++) { string s; cin>>s; if (s.size()<6||s.size()%2!=0){ cout<<"NA"<<endl; } else { if (s.at(0)=='>'&&s.at(1)=='\''&&s.at(s.size()-1)=='~') { string tmp=s.substr(2,s.size()-3); string front=tmp.substr(0,(tmp.size()-1)/2); string back=tmp.substr((tmp.size()+2)/2,(tmp.size()-1)/2); if (front==back) { cout<<"A"<<endl; } else { cout<<"NA"<<endl; } } else if (s.at(0)=='>'&&s.at(1)=='^'&&s.at(s.size()-1)=='~'&&s.at(s.size()-2)=='~') { string center=s.substr(2,s.size()-4); for (int j=0;j<center.size();j+=2) { if (center.at(j)!='Q'||center.at(j+1)!='=') { cout<<"NA"<<endl; break; } if (j==center.size()-2) { cout<<"B"<<endl; } } } else { cout<<"NA"<<endl; } } } }