-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday_45.cpp
92 lines (70 loc) · 1.58 KB
/
day_45.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Name - Himanshu pokhriyal
Date - 9 May, 2024
Version - c++17
Ques-1 Candy Distribution
Link - https://www.codechef.com/practice/course/logical-problems/DIFF800/problems/CANDYDIST
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while( t-- ){
int n,m;
cin>>n>>m;
int final = n/m;
if(n%m != 0 ) cout<<"No"<<endl;
else if(final %2 != 0) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}
}
Time complexity - O(t)
Space Complexity - O(1)
Ques-2 The Last Levels
Link - https://www.codechef.com/practice/course/logical-problems/DIFF800/problems/LASTLEVELS?tab=statement
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while( t-- ){
int x,y,z;
cin>>x>>y>>z;
int totalTime = x * y;
if(x%3 != 0){
x=floor(x/3);
}
else{
x=(x/3)-1;
}
int sessionTime = totalTime + x*z;
cout << sessionTime << endl;
}
}
Time complexity - O(t);
Space complexity - O(1)
Ques-3 Blackjack
Link - https://www.codechef.com/practice/course/logical-problems/DIFF800/problems/BLACKJACK
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while( t-- ){
int a,b;
cin>>a>>b;
int z=21-(a+b);
if(z>=1 && z<=10) {
cout<<z<<endl;
}
else{
cout<<"-1"<<endl;
}
}
}
time complexity - O(t);
space complexity - O(1)
*/