#include <stdio.h> #include <string.h> #include <string> #include <iostream> #include <math.h> #include <vector> #define SZ 100005 using namespace std; int prim[SZ]; vector<int> v; void primgen() { v.push_back(2); prim[2]=0; for(int i=3;i<SZ;i+=2) { if(prim[i]==0) { v.push_back(i); for(int j=i*3;j<SZ;j+=i) prim[j]=1; } } //cout<<v.size()<<"\n"; } int main() { int mult[5]; int m,max_; string s; primgen(); while(cin>>s) { if(s=="0") break; memset(mult,0,sizeof(mult));
12578
#include <iostream> #include <string.h> #include <stdio.h> #include <math.h> #define lld long long using namespace std; int main() { int t; double PI; double l,r,A,C,w; cin>>t; PI= acos(- 1); while(t–) { cin>>l; r=l/5; w= (6*l)/10; A = w*l; C= PI*r*r; A -=C; printf("%.2lf %.2lf\n",C,A); } return 0; }
12577
#include <iostream> #include <string.h> #include <stdio.h> #include <math.h> #define lld long long using namespace std; int main() { string s; int kase=1; while(cin>>s) { if(s=="*") break; if(s=="Hajj") cout<<"Case "<<kase++<<": Hajj-e-Akbar\n"; else if(s=="Umrah") cout<<"Case "<<kase++<<": Hajj-e-Asghar\n"; } return 0; }
12531
#include <stdio.h> #include <iostream> using namespace std; int main() { int n; while(cin>>n) { if(n%6==0) printf("Y\n"); else printf("N\n"); } return 0; }
12502
/**********12502**********/ #include <iostream> #include <string.h> #include <stdio.h> #include <math.h> #define lld long long using namespace std; int main() { int t;//a= 2/15 b=1/12 double x,y,z; double extra,avg; cin>>t; while(t–) { cin>>x>>y>>z; avg=(x+y)/3; extra = x-avg; printf("%.0lf\n",(extra*z)/avg); } return 0; }
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();
12517
Theory: from 0 to 99 there are 2*10^1=20 for each 0 to 9 digits. from 0 to 999 there are 3*10^2=300 for each 0 to 9 digits. so the foemulae is for 0 to n number of 9’s n*10^(n-1) for each 0 to 9 digits. And so, for upto 445 we can find total number
12532
/*****Binary Index tree 12532******/ #include <stdio.h> #include <iostream> #include <string> #include <string.h> #include <math.h> #define SZ 100005 #define ll long long using namespace std; int num[SZ]; int neg[SZ]; int zero[SZ]; int maxInd; void update(int *arr,int ind,int val) { while(ind<maxInd) { arr[ind]+=val; ind+=(ind & (-ind)); } } int read(int *arr,int ind) { int res =0; while(ind>0)
