Skip to content

Commit 5650b8a

Browse files
authored
Merge pull request larymak#211 from Rjndrkha/main
CodeForce Program Solution
2 parents d1bf9ce + ea0514e commit 5650b8a

28 files changed

+625
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform else nknagrale
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
long long n;
8+
cin>>n;
9+
long long count=0;
10+
while(n!=0){
11+
int x=n%10;
12+
n/=10;
13+
if(x==4 || x==7){
14+
count++;
15+
}
16+
}
17+
if(count==0) {
18+
cout<<"NO"<<endl;
19+
return 0;
20+
}
21+
bool flag=true;
22+
while(count!=0){
23+
int x=count%10;
24+
count/=10;
25+
if(x!=4 && x!=7){
26+
flag=false;
27+
cout<<"NO"<<endl;
28+
break;
29+
}
30+
}
31+
if(flag) cout<<"YES"<<endl;
32+
return 0;
33+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform else nknagrale
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
string a,b;
8+
cin>>a>>b;
9+
for(auto &c: a) c=tolower(c);
10+
transform(b.begin(),b.end(),b.begin(),::tolower);
11+
cout<<a.compare(b)<<endl;
12+
return 0;
13+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform else nknagrale
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int n;
8+
cin>>n;
9+
int total=0;
10+
int min=0;
11+
while(n--){
12+
int x;
13+
cin>>x;
14+
total-=x;
15+
cin>>x;
16+
total+=x;
17+
if(total>min)
18+
min=total;
19+
}
20+
cout<<min<<endl;
21+
return 0;
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform else nknagrale
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int n;
8+
cin>>n;
9+
vector<int> v;
10+
for(int i=0;i<n;i++){
11+
int temp;
12+
cin>>temp;
13+
v.push_back(temp);
14+
}
15+
int a[n];
16+
int num=1;
17+
for(int x:v){
18+
a[x-1]=num;
19+
num++;
20+
}
21+
for(int x:a)
22+
cout<<x<<" ";
23+
return 0;
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform
3+
#include <bits/stdc++.h>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
int n;
9+
cin >> n;
10+
int maxindex=0;
11+
int minindex=0;
12+
int maxvalue=INT_MIN;
13+
int minvalue=INT_MAX;
14+
for (int i = 0; i < n; i++)
15+
{
16+
int temp;
17+
cin >> temp;
18+
if(temp>maxvalue){
19+
maxindex=i;
20+
maxvalue=temp;
21+
}
22+
if(temp<=minvalue){
23+
minindex=i;
24+
minvalue=temp;
25+
}
26+
}
27+
28+
int ans=(maxindex)+(n-minindex-1);
29+
if(minindex<maxindex){
30+
cout<<ans-1<<endl;;
31+
}else{
32+
cout<<ans<<endl;
33+
}
34+
35+
return 0;
36+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int a[4],d;
8+
cin>>a[0]>>a[1]>>a[2]>>a[3]>>d;
9+
int j;
10+
set<int> s;
11+
for(int i=0;i<4;i++){
12+
j=1;
13+
while(a[i]*j<=d){
14+
if(a[i]*j<=d) s.insert(a[i]*j);
15+
j++;
16+
}
17+
}
18+
cout<<s.size()<<endl;
19+
return 0;
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform else nknagrale
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int n,k;
8+
cin>>n>>k;
9+
vector<int> a;
10+
for(int i=0;i<n;i++){
11+
int temp;
12+
cin>>temp;
13+
a.push_back(temp);
14+
}
15+
int c=a[k-1];
16+
int count=0;
17+
for(int x:a){
18+
if(x>=c && x>0) count++;
19+
}
20+
cout<<count<<endl;
21+
return 0;
22+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// code by Susritha
2+
// cf handle:Susritha.S
3+
4+
#include <bits/stdc++.h>
5+
#define ll long long int
6+
#define pb push_back
7+
#define mp make_pair
8+
using namespace std;
9+
int main(){
10+
ll t;
11+
cin>>t;
12+
while(t--){
13+
ll n;
14+
cin>>n;
15+
ll a[n],i,j;
16+
ll sus=0;
17+
for(i=0;i<n;i++){
18+
cin>>a[i];
19+
}
20+
for(i=0;i<n;i++){
21+
while(a[i]>n){
22+
a[i]/=2;
23+
}
24+
}
25+
sort(a,a+n);
26+
map<ll,ll>m;
27+
for(i=0;i<n;i++){
28+
if(m[a[i]]==0){
29+
m[a[i]]++;
30+
}
31+
else{
32+
while(a[i]>0){
33+
if(m[a[i]]==0){
34+
m[a[i]]++;
35+
break;}
36+
else{
37+
a[i]/=2;
38+
}
39+
40+
}
41+
if(a[i]==0){
42+
sus=1;
43+
break;
44+
}
45+
}
46+
}
47+
for(auto it=m.begin();it!=m.end();it++){
48+
if(it->second==0){
49+
sus=1;
50+
break;
51+
}
52+
}
53+
if(sus==0){
54+
cout<<"YES"<<endl;
55+
}
56+
else{
57+
cout<<"NO"<<endl;
58+
}
59+
}
60+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int n;
8+
cin>>n;
9+
double a[n];
10+
double ans=0;
11+
for(int i=0;i<n;i++){
12+
cin>>a[i];
13+
ans+=a[i];
14+
}
15+
cout<<ans/n<<endl;
16+
17+
return 0;
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform
3+
#include <bits/stdc++.h>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
set<long long> s;
9+
int temp;
10+
int t = 4;
11+
while (t--)
12+
{
13+
cin >> temp;
14+
s.insert(temp);
15+
}
16+
cout<<4-s.size()<<endl;
17+
return 0;
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform else nknagrale
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int n;
8+
cin>>n;
9+
int count=0;
10+
while(n--){
11+
int x,y,z;
12+
cin>>x>>y>>z;
13+
if((x+y+z)>=2) count++;
14+
}
15+
cout<<count<<endl;
16+
return 0;
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//code by Nikhil Nagrale
2+
//nikhilnagrale2 on EveryPlatform else nknagrale
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
string s;
8+
cin>>s;
9+
set<char> a;
10+
for(char x:s) a.insert(x);
11+
if(a.size()%2==0) cout<<"CHAT WITH HER!"<<endl;
12+
else cout<<"IGNORE HIM!"<<endl;
13+
return 0;
14+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Problem: A. Roma and Lucky Numbers
2+
// Contest: Codeforces - Codeforces Round #160 (Div. 2)
3+
// URL: https://codeforces.com/contest/262/problem/A
4+
// Memory Limit: 256 MB
5+
// Time Limit: 1000 ms
6+
//
7+
// Powered by CP Editor (https://cpeditor.org)
8+
9+
#include<bits/stdc++.h>
10+
using namespace std;
11+
#define ll long long
12+
#define FAST1 ios_base::sync_with_stdio(false);
13+
#define FAST2 cin.tie(NULL);
14+
int n, k, ans, num;
15+
string s;
16+
int main(){
17+
FAST1;
18+
FAST2;
19+
20+
cin >> n >> k;
21+
for (int i = 0; i < n; i++){
22+
cin >> s;
23+
for (int j = 0; j < s.size(); j++){
24+
if (s[j] == '7' || s[j] == '4'){
25+
num ++;
26+
}
27+
}
28+
if (num <= k){
29+
ans++;
30+
}
31+
num = 0;
32+
}
33+
cout << ans << endl;
34+
return 0;
35+
36+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Problem: B. Roma and Changing Signs
2+
// Contest: Codeforces - Codeforces Round #160 (Div. 2)
3+
// URL: https://codeforces.com/contest/262/problem/B
4+
// Memory Limit: 256 MB
5+
// Time Limit: 2000 ms
6+
//
7+
// Powered by CP Editor (https://cpeditor.org)
8+
9+
#include<bits/stdc++.h>
10+
using namespace std;
11+
#define ll long long
12+
#define FAST1 ios_base::sync_with_stdio(false);
13+
#define FAST2 cin.tie(NULL);
14+
15+
16+
int main(){
17+
FAST1;
18+
FAST2;
19+
int n;int k;
20+
cin>>n>>k;
21+
int arr[n];
22+
for(int i=0;i<n;i++)
23+
cin>>arr[i];
24+
25+
int mn =INT_MAX;
26+
int sm=0;
27+
for(int i=0;i<n;i++)
28+
{
29+
mn = min(abs(arr[i]),mn);
30+
if(arr[i]<0 && k>0)
31+
arr[i] *= -1,k--;
32+
sm+=arr[i];
33+
}
34+
if(k>0 && k%2==1)
35+
sm -= 2 * mn;
36+
37+
cout<<sm;
38+
return 0;
39+
}

0 commit comments

Comments
 (0)