#include<cstdio> #include<cstring> using namespace std; int main() { int tc,c=1; scanf("%d",&tc); while (tc--) { int n,k,meet[26],cnt=0; char name[510]; scanf("%d %d %s",&n,&k,name); for (int i=0;i<26;i++) meet[i]=-1000; for (int i=0;i<n;i++) { int a=name[i]-'A'; if (meet[a]+k>=i) cnt++; meet[a]=i; } printf("Case %d: %d\n",c++,cnt); } return 0; }
Sunday, July 17, 2016
Published July 17, 2016 by Sourav Chowdhury with 0 comment
Published July 17, 2016 by Sourav Chowdhury with 0 comment
#include<cstdio> using namespace std; int main() { int tc; scanf("%d",&tc); while (tc--) { int g,l; scanf("%d%d",&g,&l); if (l%g==0) printf("%d %d\n",g,l); else printf("-1\n"); } return 0; }
Published July 17, 2016 by Sourav Chowdhury with 0 comment
#include<cstdio> #include<cstring> #include<cmath> using namespace std; int main() { int tc,a,b,dif; char s[10]; scanf("%d",&tc); while (tc--) { scanf("%s",s); a=b=0; for ( int i=0;i<3;i++) a=a*26+s[i]-'A'; for (int i=4;i<8;i++) b=b*10+s[i]-'0'; if (abs(a-b)<101) printf("nice\n"); else printf("not nice\n"); } return 0; }
Saturday, July 16, 2016
Published July 16, 2016 by Sourav Chowdhury with 0 comment
#include<cstdio> #include<cmath> using namespace std; int main() { int t,n; scanf("%d",&t); while (t--) { scanf("%d",&n); int ans=n*(n-1)/2+n*(n-1)*(n-2)*(n-3)/24+1; printf("%d\n",ans); } return 0; }
Published July 16, 2016 by Sourav Chowdhury with 0 comment
#include<cstdio> #include<cmath> using namespace std; #define pi 2*acos(0) int main() { double r,n,ans; while (scanf("%lf%lf",&r,&n)!=EOF) { ans=n*r*r*sin(2.0*pi/n)/2; printf("%.3lf\n",ans); } return 0; }
Published July 16, 2016 by Sourav Chowdhury with 0 comment
#include <cstdio> #include <cstring> #include <iostream> #include <string> using namespace std; int main() { string s; int tc, a, b, c= 1; cin >> tc; while (tc--) { cin >> a >> s; b = s.length() > 3 ? (int) s[3] - '0' : 0; cout << "Case " << c++ << ": " << a * 0.5 + b * 0.05 << endl; } return 0; }
Published July 16, 2016 by Sourav Chowdhury with 0 comment
#include<cstdio> using namespace std; int main() { double a,b,c,x; int s=1; while (1) { scanf("%lf%lf%lf",&a,&b,&c); if (a==-1) return 0; printf("Set %d:\n",s++); x=b*b-a*c; if (x>0) { double ans=a*c*(a+2*b+c)/x; if (ans>0) printf("%.4lf\n",ans); else printf("Poor King!\n"); } else printf("Poor King!\n"); } return 0; }
Subscribe to:
Posts (Atom)