Posts

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 &...