1585

#include <iostream> #include <stdio.h> #include <vector> #include <math.h> #include <string.h> using namespace std; int main() { int t,toAdd,sum; string s; cin>>t; while(t–) { cin>>s; sum = 0; toAdd = 0; for(int i=0;i<s.size();i++) { if(s[i]=='X') toAdd=0; else if(s[i]=='O') toAdd++; sum+=toAdd; } cout<<sum<<"\n"; } return 0; } //OOXXOXXOOO  

1062

WA Code: #include <iostream> #include <map> #include <string> using namespace std; map<char,int> m,np; //vector<char> v; int main() { string str; int cnt; int kase=1; while(cin>>str) { if(str=="end") break; cnt=1; np.clear(); m.clear(); for(int i=0;i<str.size();i++) { if(m[str[i]]<(i+1)) m[str[i]]=i+1; } for(map<char,int>::iterator ii=m.begin();ii!=m.end();++ii) { cout<<ii->first<<" "<<ii->second<<"\n"; int pos=ii->second; char c=ii->first; int f=0; for(int i=0;i<pos;i++) { if(str[i]<c && np[str[i]]==0) {

12801

#include <iostream> #include <stdio.h> using namespace std; int circum[10001]; int main() { int C,N; int res=0; double div; while(cin>>C) { cin>>N; div=(double)C/N; for(int i=0;i<N;i++) { cin>>circum[i]; } circum[N]=circum[0]+C; for(int i=circum[0];i<circum[1];i++) { int dis=i; res=0; int f=1; for(int j=1;j<=N;j++) { if(dis<circum[j] && circum[j]<=(dis+div)) dis+=div; else { f=0; break; } } if(f) { res=1; break; } }

12802

#include <iostream> #include <stdio.h> #include <vector> using namespace std; int prime[1000001]; vector<int> v; int palin(int a) { if(a<=11) return 1; int org=a; int r=0; while(a) { r*=10; r+=(a%10); a/=10; } if(r==org) return 1; return 0; } int main() { for(int j=1;j<1000001;j++) prime[j]=0; for(int i=2;i<1000001/2;i++) { if(prime[i]==0) for(int j=i+i;j<1000001;j+=i) prime[j]=1; } for(int i=1;i<1000001;i++) { if(prime[i]==0) {

755

#include <iostream> #include <map> #include <string> using namespace std; map<char,int> mp; map<int,int> np; int main() { mp['A']=2; mp['B']=2; mp['C']=2; mp['D']=3; mp['E']=3; mp['F']=3; mp['G']=4; mp['H']=4; mp['I']=4; mp['J']=5; mp['K']=5; mp['L']=5; mp['M']=6; mp['N']=6; mp['O']=6; mp['P']=7; mp['R']=7; mp['S']=7; mp['T']=8; mp['U']=8; mp['V']=8; mp['W']=9; mp['X']=9; mp['Y']=9; mp['0']=0; mp['1']=1; mp['2']=2; mp['3']=3; mp['4']=4; mp['5']=5; mp['6']=6; mp['7']=7; mp['8']=8; mp['9']=9; int t,n,num; string str; cin>>t;

10852

#include <iostream> #include <map> #include <fstream> /* ofstream out; out.open("o.txt"); for(int i=0;i<11000;i++) prime[i]=0; for(int i=2;i<11000/2;i++) { if(prime[i]==0) for(int j=i+i;j<11000;j+=i) { prime[j]=1; } } int cnt=0; for(int i=2;i<10000;i++) { if(prime[i]==0) { out<<i<<","; cnt++; if(cnt%10==0) out<<"\n"; } } cout<<cnt<<"\n"; out.close(); */ using namespace std; //int prime[11000]; int prime[1230]={0,2,3,5,7,11,13,17,19,23,29, 31,37,41,43,47,53,59,61,67,71, 73,79,83,89,97,101,103,107,109,113, 127,131,137,139,149,151,157,163,167,173, 179,181,191,193,197,199,211,223,227,229, 233,239,241,251,257,263,269,271,277,281, 283,293,307,311,313,317,331,337,347,349, 353,359,367,373,379,383,389,397,401,409, 419,421,431,433,439,443,449,457,461,463, 467,479,487,491,499,503,509,521,523,541,

12335

Problem Solving Head start: Discussion is quoted from this link: So before proceed recall,if a<b<c<d and string is- abcd, there are 24 permutation,where 1-6 permutation start with smallest, here a. 7-12 permutation start with second smallest, here b. 13-18 permutation start with third smallest, here c. 19-24 permutation start with fourth smallest, here d. lets

12397

#include <iostream> #include <stdio.h> #include <math.h> #include <string> #include <map> using namespace std; map<int,char> mp; int main() { int n,p; string str; mp[1]='I'; mp[5]='V'; mp[10]='X'; mp[50]='L'; mp[100]='C'; mp[500]='D'; mp[1000]='M'; //mp[2]= while(cin>>n) { str=""; int cnt=0; p=0; if(n>=1000) { p=n/1000; cnt+=p*4; n-=1000*p; } p=0; if(n>=100) { p=n/100; if(p==1) cnt+=2; else if(p==2) cnt+=4; else if(p==3) cnt+=6; else

343

#include <iostream> #include <string> #include <cstring> #include <string.h> using namespace std; unsigned long long decOf(string s,int a) { unsigned long long d; unsigned long long _pow=1; unsigned long long r=0; if((s[s.size()-1]-'0')>=0 && (s[s.size()-1]-'0')<=9) d=(s[s.size()-1]-'0'); else d=(s[s.size()-1]-55); if(d>=a) { return -1; } r+=(d*1); for(int i=s.size()-2;i>=0;i–) { _pow*=a; if((s[i]-'0')>=0 && (s[i]-'0')<=9) d=(s[i]-'0'); else d=(s[i]-55); if(d>=a) { return