Posts

Showing posts from October, 2018

codeforces 379A problem solution in simple c/c++

# include<iostream> using namespace std; int main () {     int a,b,c,d,e,sum=0;     cin>>a>>b;     sum=a;     c=a/b;     sum=sum+c;     e=a%b;     c=c+e;    // cout<<c;     while(c>=b)     {        e=c%b;         c=c/b;         sum=sum+c;         //cout<<sum<<endl;         //e=c%b;        // cout<<"e=";         //cout<<e<<endl;         c=c+e;         //cout<<"c=";         //cout<<c<<endl;         if(c==b)         {             sum=sum+1;             break;         } ...

379A-NEW YEAR CANDLES SOLUTION IN SIMPLE C++

# include<iostream> using namespace std; int main () {     int a,b,c,d,e,sum=0;     cin>>a>>b;     sum=a;     c=a/b;     sum=sum+c;     e=a%b;     c=c+e;    // cout<<c;     while(c>=b)     {        e=c%b;         c=c/b;         sum=sum+c;         //cout<<sum<<endl;         //e=c%b;        // cout<<"e=";         //cout<<e<<endl;         c=c+e;         //cout<<"c=";         //cout<<c<<endl;         if(c==b)         {             sum=sum+1;             break;         } ...

268A problem solution in c++

// 268A.cpp : This file contains the 'main' function. Program execution begins and ends there. #include <iostream> #include<string> using namespace std; int main() { int anis[1000]; int n, i, j=1, a, b; cin >> n; for (i = 0;i < n;i++) { cin >> a >> b; anis[j] = a; j++; anis[j] = b; j++; } int z, v=0; z = j; for (i = 1;i < z;i+=2) { for (j = 2;j < z;j += 2) { if (anis[i] == anis[j]) { v++; } } } cout << v << endl;   } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: //   1. Use the Solution Explorer window to add/manage files //   2. Use the Team Explorer window to connect to source control //   3. Use the Output window to see build output and other messages //   4. Use the Error List window to view errors ...

codeforces 268A problem solution in c/c++

#include <iostream> #include<string> using namespace std; int main() { int anis[1000]; int n, i, j=1, a, b; cin >> n; for (i = 0;i < n;i++) { cin >> a >> b; anis[j] = a; j++; anis[j] = b; j++; } int z, v=0; z = j; for (i = 1;i < z;i+=2) { for (j = 2;j < z;j += 2) { if (anis[i] == anis[j]) { v++; } } } cout << v << endl;   }

472 problem solution in c++

// 472A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n,v=0,b=0,m=0,e=0,cc=0,bb=0; cin >> n; if (n % 2 == 0) { v = n; v = v / 2; if (v % 2 == 0) { b = v; m = v; } else if (v % 2 == 1) { b = v - 1; m = v + 1; } } else if (n % 2 == 1) { e = n; e = e / 2; b = e; m = e + 1; for (int j = 0;j < m;j++) { for (int i = 2;i < m / 2;i++) { if (b%i == 0) { cc++; } if(m%i==0) { bb++; } } if (bb == 0 && cc == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (bb > 0 && cc == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (cc > 0 && bb == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (bb > 0 &...

472A-Design The Tutorial: Learn from Math solution in c++

// 472A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n,v=0,b=0,m=0,e=0,cc=0,bb=0; cin >> n; if (n % 2 == 0) { v = n; v = v / 2; if (v % 2 == 0) { b = v; m = v; } else if (v % 2 == 1) { b = v - 1; m = v + 1; } } else if (n % 2 == 1) { e = n; e = e / 2; b = e; m = e + 1; for (int j = 0;j < m;j++) { for (int i = 2;i < m / 2;i++) { if (b%i == 0) { cc++; } if(m%i==0) { bb++; } } if (bb == 0 && cc == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (bb > 0 && cc == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (cc > 0 && bb == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (bb > 0 &...

codeforces 472A problem solution in simple c/c++

// 472A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n,v=0,b=0,m=0,e=0,cc=0,bb=0; cin >> n; if (n % 2 == 0) { v = n; v = v / 2; if (v % 2 == 0) { b = v; m = v; } else if (v % 2 == 1) { b = v - 1; m = v + 1; } } else if (n % 2 == 1) { e = n; e = e / 2; b = e; m = e + 1; for (int j = 0;j < m;j++) { for (int i = 2;i < m / 2;i++) { if (b%i == 0) { cc++; } if(m%i==0) { bb++; } } if (bb == 0 && cc == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (bb > 0 && cc == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (cc > 0 && bb == 0) { b = b - 1; m = m + 1; bb = 0; cc = 0; } else if (bb > 0 &...

A.Arrival of the general codefoces problem solution in simple c/c++

// 144A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n, anis[100], anis1[100]; cin >> n; for (int i = 1;i <= n;i++) { cin >> anis[i]; anis1[i] = anis[i]; } int lo = anis[1], hi = anis[1], t; for (int i = 1;i <= n;i++) { if (lo > anis[i]) { t = lo; lo = anis[i]; anis[i] = t; } if (hi < anis[i]) { t = hi; hi = anis[i]; anis[i] = t; } } //cout << lo << endl << hi; int a1[100], b1[100], c = 1, f = 1, xx, zz; for (int i = 1;i <= n;i++) { //cout << endl << anis[i]<<endl; if (anis1[i] == lo) { a1[c] = i; c++; //cout << endl<<"anis"; } if (anis1[i] == hi) { b1[f] = i; f++; //cout << endl << "anis"; } } xx = a1[c - 1]; zz = b1[1]; //cout <...

144A problem solution in simple c/c++

// 144A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n, anis[100], anis1[100]; cin >> n; for (int i = 1;i <= n;i++) { cin >> anis[i]; anis1[i] = anis[i]; } int lo = anis[1], hi = anis[1], t; for (int i = 1;i <= n;i++) { if (lo > anis[i]) { t = lo; lo = anis[i]; anis[i] = t; } if (hi < anis[i]) { t = hi; hi = anis[i]; anis[i] = t; } } //cout << lo << endl << hi; int a1[100], b1[100], c = 1, f = 1, xx, zz; for (int i = 1;i <= n;i++) { //cout << endl << anis[i]<<endl; if (anis1[i] == lo) { a1[c] = i; c++; //cout << endl<<"anis"; } if (anis1[i] == hi) { b1[f] = i; f++; //cout << endl << "anis"; } } xx = a1[c - 1]; zz = b1[1]; //cout ...

codeforces 144A problem solution in c/c++

// 144A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n, anis[100], anis1[100]; cin >> n; for (int i = 1;i <= n;i++) { cin >> anis[i]; anis1[i] = anis[i]; } int lo = anis[1], hi = anis[1], t; for (int i = 1;i <= n;i++) { if (lo > anis[i]) { t = lo; lo = anis[i]; anis[i] = t; } if (hi < anis[i]) { t = hi; hi = anis[i]; anis[i] = t; } } //cout << lo << endl << hi; int a1[100], b1[100], c = 1, f = 1, xx, zz; for (int i = 1;i <= n;i++) { //cout << endl << anis[i]<<endl; if (anis1[i] == lo) { a1[c] = i; c++; //cout << endl<<"anis"; } if (anis1[i] == hi) { b1[f] = i; f++; //cout << endl << "anis"; } } xx = a1[c - 1]; zz = b1[1]; //cout ...

codeforces 451A problem solution in c/c++

// codeforces 451A problem solution.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n, m,i=0,j=0,k=0; cin >> n >> m; k = n + m; while (1) { if (n >= 1&&m>=1) { n = n - 1; m = m - 1; i++; } else { break; } } //cout << i; if (i % 2 == 0) { cout << "Malvika"; } else { cout << "Akshat"; } return 0; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: //   1. Use the Solution Explorer window to add/manage files //   2. Use the Team Explorer window to connect to source control //   3. Use the Output window to see build output and other messages //   4. Use the Error List window to view errors //   5. Go to Pr...

codeforces 405A solution in simple c/c++

// 405A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n,anis[100],c,v,t; cin >> n; for (int j = 0;j < n;j++) { cin >> anis[j]; } c = anis[0]; for (int i = 0;i < n;i++) { for (int j = i+0;j < n;j++) { if (anis[i] > anis[j]) { t = anis[i]; anis[i] = anis[j]; anis[j] = t; } } } for (int i = 0;i < n;i++) { cout << anis[i]<<" "; } } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: //   1. Use the Solution Explorer window to add/manage files //   2. Use the Team Explorer window to connect to source control //   3. Use the Output window to see build output and other messages //   4. Use the Error List window to view errors /...

codeforces 344A problem solution in simple c/c++

// 344A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n,anis[100000],c=0,d=0,e=0; cin >> n; for (int i = 1;i <= n;i++) { cin >> anis[i]; } for (int j = 1;j <= n;j++) { if (anis[j] == 01) { d++; if (c > 0) { e++; c = 0; } }     else if (anis[j] == 10) { c++; if (d > 0) { e++; d = 0; } } } cout << e + 1; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: //   1. Use the Solution Explorer window to add/manage files //   2. Use the Team Explorer window to connect to source control //   3. Use the Output window to see build output and other messages //   4. Use the Error List window to view e...

codeforces 520A problem solution in c/c++

// 520A.cpp : This file contains the 'main' function. Program execution begins and ends there. // //# include "pch.h" # include <iostream> # include<string> using namespace std; int main() { string anis; string anis1; int nn,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,ii=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0; cin >> nn; cin >> anis; for (int i = 0;i < nn;i++) { if (anis[i] == 'A' || anis[i] == 'a') { a++; } else if (anis[i] == 'B' || anis[i] == 'b') { b++; } else if (anis[i] == 'C' || anis[i] == 'c') { c++; } if (anis[i] == 'D' || anis[i] == 'd') { d++; } else if (anis[i] == 'e' || anis[i] == 'E') { e++; } else if (anis[i] == 'F' || anis[i] == 'f') { f++; } if (anis[i] == 'G' || anis[i] == 'g') { g++; ...

codeforces 617A solution in c/c++

// 617A.cpp : This file contains the 'main' function. Program execution begins and ends there. // //#include "pch.h" #include <iostream> using namespace std; int main() { int n,a,b,c,d,e,cc=0,aa=0; cin >> n; a = 1; b = 2; c = 3; d = 4; e = 5; while (1) {     if(n>=e)         {             cc=n%e;             aa=aa+n/e;             n=cc;             if(cc==0)             {                 cout<<aa;                 break;             }         }         else if(cc>=d||n>=d)         {             cc=cc%d;             aa=...

codeforces 58A solution in c/c++

// 58A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> # include<string> using namespace std; int main() { string anis; string aa[100]; cin >> anis; int j = 0,hh=0,v; int ee = 0, ll = 0, oo = 0; v = anis.size(); for (int i = 0;i < v;i++) { if (anis[i] == 'h'&&hh==0) { aa[j] ='h'; hh++; j++; } else if (anis[i] == 'e'&&ee== 0&&hh==1) { aa[j] = 'e'; ee++; j++; } else if (anis[i] == 'l'&&ll <= 1&&ee==1) { aa[j] ='l'; ll++; j++; } else if (anis[i] == 'o'&&oo == 0&&ll==2) { aa[j] = 'o'; oo++; j++; } } if (aa[0]=="h"&&aa[1]=="e"&&aa[2]=="l"&&aa[3]=="l"&&aa[4]=="o") { cout << ...

codeforces 236A solution in c/c++

// 236A.cpp : This file contains the 'main' function. Program execution begins and ends there. // # include<string> #include <iostream> using namespace std; int main() { string anis; cin >> anis; int vv = anis.size(); int cc = 0; int a=0, b=0, c=0, d=0, e=0, f=0, g=0, h=0, ii=0, j=0, k=0, l=0, m=0, n=0, o=0, p=0, q=0, r=0, s=0, t=0, u=0, v=0, w=0, x=0, y=0, z=0; for (int i = 0;i < vv;i++) { if (anis[i] == 'a') { if (a == 0) { cc++; a++; } } else if (anis[i] == 'b') { if (b == 0) { cc++; b++; } } else if (anis[i] == 'c') { if (c == 0) { cc++; c++; } } else if (anis[i] == 'd') { if (d == 0) { cc++; d++; } } else if (anis[i] == 'e') { if (e == 0) { cc++; e++; } } else if (anis[i] == 'f') { if (f == 0) { cc++; f...

codeforces 339A solution in c/c++

// 339A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> # include<string> using namespace std; int main() { string anis; cin >> anis; int v = anis.length();//determine string length int c = anis[0]; int temp; for (int i = 0;i < v;i+=2) { for (int j = i + 2;j < v;j+=2) { if (anis[i] > anis[j]) { temp = anis[i]; anis[i] = anis[j]; anis[j] = temp; } } } cout << anis;     }

codefoces 116A solution in c/c++

// 116A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; int main() { int n,anis[100]; int a, b,c=0,d,e; int i = 0; int temp; cin >> n; e = n; while (n--) { cin >> a >> b; c =c+ b-a; anis[i] = c; i++; } d = anis[0]; for (int j = 1;j < e;j++) { if (d < anis[j]) { temp = d; d = anis[j]; anis[j] = temp; } } cout << d; }

codeforces 263A solution in c/c++

// codeforces 263A.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> # include<stdlib.h> using namespace std; int main() { int a[100][100]; int i, j, k, l=0, m=0, n; for (i = 1;i <= 5;i++) { for ( j = 1;j <= 5;j++) { cin >> a[i][j]; } } for (i = 1;i <= 5;i++) { for ( j = 1;j <= 5;j++) { if (a[i][j] == 1) { l = i; m = j; break; } } } int dd = abs(3 - l); int ddd = abs(3 - m); int ff = dd + ddd; cout << ff; return 0; }

codeforcess 113A solution in c/c++

// 131A.cpp : This file contains the 'main' function. Program execution begins and ends there. #include <iostream> # include<string> using namespace std; int main() { string anis; string anis2[100]; cin >> anis; int y = 0, m = 0; int g = 0; int lower = 0; int v = anis.size(); for (int i = 0;i < v;i++) { if (anis[i] < 92) { g++; } } if (anis[0] > 92) { y++; } for (int i = 1;i < v;i++) { if (anis[i] < 92) { y++; } } if (g == v) { for (int i = 0;i < v;i++) { if (anis[i] < 91) { anis2[i] = anis[i] + 32; } } for (int j = 0;j < v;j++) { cout << anis2[j]; } } else if (v ==y) { for (int i = 1;i < v;i++)      { if (anis[i] < 91) { anis2[i] = anis[i] + 32; } } if (anis[0] > 91) { anis2[0] = anis[0] - 32; } for (int j = 0;j < v;j++) { cout << anis2...

codeforces 122A problem solution in simple c

# include<stdio.h> int main () {     int n,b,c=0,d,e;     int r=0,w=0;     int aaa[100];     scanf("%d",&n);     if(n%4==0||n%47==0||n%744==0||n%7==0)     {         printf("YES");     }     else     {     while(1)     {         b=n%10;         aaa[c]=b;         c++;         n=n/10;         if(n==0)         {             break;         }     }     w=c;     //printf("%d\n\n",c);     for(d=c-1;d>=0;d--)     {         if(aaa[d]==7||aaa[d]==4)         {             r++;         }     }     i...