Skip to content

Commit 03106e9

Browse files
committed
codemarshal problem section
1 parent e6fb280 commit 03106e9

25 files changed

+614
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include<bits/stdc++.h>
2+
#include<stdio.h>
3+
#include<math.h>
4+
#include<vector>
5+
#include<algorithm>
6+
#include<set>
7+
#define sz 1000001
8+
using namespace std;
9+
vector<int>prime;
10+
vector<long long int>ans;
11+
bool flag[1000001];
12+
int prsz;
13+
void sieve(void)
14+
{
15+
int i,j,add;
16+
flag[0]=flag[1]=1;
17+
prime.push_back(2);
18+
for(i=4; i<sz; i+=2)
19+
flag[i]=1;
20+
for(i=3; i<sz; i+=2)
21+
{
22+
if(!flag[i])
23+
{
24+
prime.push_back(i);
25+
if(sz/i>=i)
26+
{
27+
add=i*2;
28+
for(j=i*i; j<sz; j+=add)
29+
flag[j]=1;
30+
}
31+
}
32+
33+
}
34+
}
35+
36+
int main()
37+
{
38+
sieve();
39+
long long int i,k,szp,j;
40+
szp=prime.size();
41+
// printf("total prime %lld\n",szp);
42+
// for(i=0; i<=20; i++)
43+
// printf("%d ",prime[prime.size()-1]);
44+
// printf("\n\n\n");
45+
for(i=0; i<sz; i++)
46+
{
47+
if(!flag[i])
48+
for(j=i*i; j<1000000000001; j*=i)
49+
ans.push_back(j);
50+
51+
// for(j=prime[i]*prime[i];j<1000000000001;j*=prime[i])
52+
// ans.push_back(j); //does not work :( ;(
53+
}
54+
55+
56+
sort(ans.begin(),ans.end());
57+
int tst,count,ansz;
58+
ansz=ans.size();
59+
// printf("total ans %d\n",ansz);
60+
long long x,y;
61+
scanf("%d",&tst);
62+
while(tst--)
63+
{
64+
count=0;
65+
scanf("%lld %lld",&x,&y);
66+
i=0;
67+
while(ans[i]<x)i++;
68+
for(; i<ansz && ans[i]<=y; i++)
69+
count++;
70+
printf("%d\n",count);
71+
72+
}
73+
74+
return 0;
75+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main ()
5+
{
6+
int t,i,j,l;
7+
char n[105],ch;
8+
cin>> t;
9+
getchar();
10+
for(i=1; i<=t; i++)
11+
{
12+
gets(n);
13+
l=strlen(n);
14+
cout<<"Case "<< i<<": ";
15+
for(j=0; j<l;j++)
16+
{
17+
putchar(toupper(n[j]));
18+
}
19+
cout<<"\n";
20+
}
21+
return 0;
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
#include<stdio.h>
3+
int main ()
4+
{
5+
printf("Yaayy!! Bangladesh Won!!\n");
6+
return 0;
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<bits/stc++.h>
2+
#include<iostream>
3+
#include<cmath>
4+
#include<iomanip>
5+
using namespace std;
6+
7+
int main()
8+
{
9+
10+
11+
int T;
12+
cin >> T;
13+
for(int t = 1; t <= T; t++){
14+
double a,b,c;
15+
cin >> a >> b >> c;
16+
double s = (a+b+c)/2;
17+
double p = s*(s-a)*(s-b)*(s-c);
18+
double r = sqrt(p);
19+
cout<<"Case "<<t<<": "<<fixed<<setprecision(10) <<r <<endl;
20+
}
21+
return 0;
22+
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include<bits/stdc++.h>
2+
#include<iostream>
3+
using namespace std;
4+
int main(){
5+
6+
int T;
7+
cin >> T;
8+
for(int t = 1; t <= T; t++){
9+
int n,num,sum = 0;
10+
cin >> n;
11+
for(int i = 0; i < n; i++){
12+
cin >> num;
13+
sum+=num;
14+
}
15+
cout << "Case " << t << ": " << sum/n << endl;
16+
}
17+
return 0;
18+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
cout<<"Budget of each portion is 174551 BDT."<<endl;
6+
return 0;
7+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//#include<bits/stdc++.h>
2+
//using namespace std;
3+
//int main()
4+
//{
5+
// long long a,n,T,t,i;
6+
// //cin>>T;
7+
// scanf("%ll",&T);
8+
// for(t=1;t<=t;t++)
9+
// {
10+
// set<long long>res;
11+
// //cin>>n;
12+
// scanf("%ll",&n);
13+
// for(i=0;i<n;i++)
14+
// {
15+
// //cin>>a;
16+
// scanf("%ll",&a);
17+
// res.insert(a);
18+
// }
19+
// cout<<"Case "<<t<<": "<<res.size()<<endl;
20+
// }
21+
// return 0;
22+
//}
23+
//
24+
25+
26+
#include<bits/stdc++.h>
27+
using namespace std;
28+
/*
29+
*
30+
* Towfiqul Islam
31+
* International Islamic University Chittagong (IIUC)
32+
*
33+
*/
34+
int main(){
35+
36+
long long a,T,n;
37+
38+
scanf("%lld",&T);
39+
for(int t = 1; t <= T; t++){
40+
set<long long> res;
41+
scanf("%lld",&n);
42+
for(int i = 0; i < n; i++){
43+
scanf("%lld",&a);
44+
res.insert(a);
45+
}
46+
printf("Case %lld: %d\n",t,res.size());
47+
}
48+
return 0;
49+
}
50+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
int a,n,i,sum=0;
6+
cin>>n;
7+
for(i=0;i<n;i++)
8+
{
9+
cin>>a;
10+
if(!(i%2))sum+=a;
11+
}
12+
cout<<sum<<endl;
13+
return 0;
14+
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include<iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
cout<<"Yaayy!! Bangladesh Won!!"<<endl;
6+
return 0;
7+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int T;
7+
cin>>T;
8+
for(int t = 1; t <= T; t++){
9+
int n,c[101] = {0},tmp;
10+
cin>>n;
11+
for(int i = 0; i < n; i++){
12+
cin>>tmp;
13+
c[tmp]++;
14+
}
15+
int h = 0,m;
16+
for(int i = 0; i <= 100; i++){
17+
if(c[i] >= h){
18+
h = c[i];
19+
m = i;
20+
}
21+
}
22+
cout<<"Case "<<t<<": "<<m<<" "<<h<<endl;
23+
}
24+
25+
}

0 commit comments

Comments
 (0)