12345

#include <iostream> #include <string.h> #include <map> using namespace std; bool trace[1000005]; int a[50005]; int main() { int n,q,res; char c; int idx,val; cin>>n>>q; for(int i=0;i<n;i++) { cin>>a[i]; } while(q–) { cin>>c>>idx>>val; if(c=='M') { a[idx]=val; } else if(c=='Q') { res=0; for(int i=idx;i<val;i++) { if(trace[a[i]]==0) res++; trace[a[i]]=1; } for(int i=idx;i<val;i++) trace[a[i]]=0; cout<<res<<"\n"; } } }  

12554

#include <iostream> #include <string> using namespace std; string str[105]; string song[16]={"Happy", "birthday", "to", "you", "Happy", "birthday", "to", "you", "Happy", "birthday", "to", "Rujia", "Happy", "birthday", "to", "you",}; int main() { int n; int i=0; cin>>n; int org = n; while(n–) { cin>>str[i++]; } n=org; if(org<=16) { for(int j=0;j<16;j++) { cout<<str[j%i]<<": "; cout<<song[j]<<"\n"; } } else {

12527

#include <stdio.h> #include <iostream> #include <math.h> #include <string.h> #include <time.h> using namespace std; int trace[5001]; int main() { //clock_t t1,t2; //t1=clock(); int cnt=0; int arr[10]; for(int i=1;i<=5000;i++) { int tmp=i; trace[i]=cnt; memset(arr,0,sizeof(arr)); while(tmp) { arr[tmp%10]++; if(arr[tmp%10]>1) { cnt++; trace[i]=cnt; break; } tmp/=10; } } int n,m; while(cin>>n>>m) { cout<<(m-n+1)-(trace[m] – trace[n-1])<<"\n"; } //cout<<cnt<<"\n"; /* t2=clock();

12541

#include <iostream> #include <sstream> #include <stdio.h> #include <string> #include <math.h> using namespace std; int main() { int n; double max_,min_; double day,month,yr; string s,name,young,old; stringstream ss; bool f=false; cin>>n; //getchar(); while(n–) { cin>>name>>day>>month>>yr; yr+=((month/12)+(day/365)); if(!f) { max_=yr; young = name; min_=yr; old = name; f=1; } else { if(yr>max_) { max_=yr; young = name; }

12543

#include <iostream> #include <string> #include <math.h> using namespace std; int main() { string s,maxStr,a; int max_=0; int len=0; maxStr=""; while(cin>>s) { if(s=="E-N-D") break; len=0; a=""; for(int i=0;i<s.size();i++) { if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z') || s[i]=='-') { len++; if(s[i]>='A' && s[i]<='Z') a.append(1u,s[i]+32); else a.append(1u,s[i]); } } if(len>max_) { max_=len; maxStr=a; } } cout<<maxStr<<"\n"; return

1523

#include <iostream> #include <stdio.h> #include <map> #include <math.h> #include <algorithm> using namespace std; //M = sqrt(sumof(Mv)^2+sumof(Mh)^2) int per[8]={0,1,2,3,4,5,6,7}; int arr[322561]; int inp[8]; int main() { double Mv,Mh; double _max; int cnt=1; for(int i=0;i<8;i++) { arr[cnt]=per[i]; cnt++; } while(next_permutation(per,per+8)) { for(int i=0;i<8;i++) { arr[cnt]=per[i]; //cout<<arr[cnt]<<" "; cnt++; } } //cout<<cnt<<"\n"; while(cin>>inp[0]) { int sum=0; sum+=inp[0]; cin>>inp[1];

763

#include <iostream> #include <string> #include <stdio.h> #include <string.h> #define max(a,b) (a)>(b)?(a):(b) #define size 350 using namespace std; struct bignum{ int s[size]; int len; bignum() { len = 1; memset(s,0,sizeof(s)); } bignum operator = (const char *str) { len = strlen(str); for(int i= 0;i<len;i++) { s[len-1-i] = str[i]-'0'; } return *this; } bignum operator = (const

1584

#include <iostream> #include <string> using namespace std; int main() { string s,s1,p; int t; cin>>t; /*if("CCTC" > "CCCT") cout<<"CCTC"<<"\n"; else cout<<"CCCT"<<"\n"; */ while(t–) { cin>>s; p=s; for(int i=1;i<p.size();i++) { s1=""; s1.append(1u,p[i]); if((i+1)<p.size()) for(int j=i+1;j<p.size();j++) s1.append(1u,p[j]); if(s1.size()!=p.size()) { for(int k=0;k<i;k++) s1.append(1u,p[k]); } //cout<<s1<<" = s1\n"; if(s1<s) s = s1; } cout<<s<<"\n"; } return 0; }  

12820

#include <iostream> #include <map> #include <string> using namespace std; map<int,int> np; map<char,int> mp; int main() { int n,kase=1; string s; while(cin>>n) { int cool=0; for(int i=0;i<n;i++) { cin>>s; if(s.size()==1) continue; mp.clear(); np.clear(); for(int i=0;i<s.size();i++) { mp[s[i]]++; } for(map<char,int>::iterator ii=mp.begin();ii!=mp.end();++ii) { np[ii->second]=1; } if(np.size()==mp.size()) cool++; } cout<<"Case "<<kase++<<": "<<cool<<"\n"; } }  

1583

#include <iostream> #include <algorithm> #include <vector> #include <map> #define lld long long using namespace std; int n; int digit_generator(int num) { int r=num; while(num) { r+=(num%10); num/=10; } if(r==n) return r; else return 0; } int main() { int t; cin>>t; while(t–) { cin>>n; if(n==11) { cout<<10<<"\n"; continue; } if(n<10) { if(n%2==0) cout<<n/2<<"\n"; else cout<<0<<"\n";