#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; #define pf printf #define sf scanf #define loop(i, n) for(i=0; i<n; i++) #define MAX 100 int min(int n, int m) { if(n>m) return m; else return n; } int main() { int n, m; cin >> n >> m; int temp = min(n, m); if(temp & 1) cout << "Akshat" << endl; else cout << "Malvika" << endl; return 0; }
Friday, May 1, 2015
451A - Game With Sticks (Codeforces)
454A. Little Pony and Crystal Mine(Codeforces)
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; #define pf printf #define sf scanf #define MAX 105 char a[MAX][MAX]; int main() { int i , j, n, temp=0, mid=0; memset(a, '*', sizeof(a)); sf("%d", &n); mid = (n-1)/2; for(i=0; i<=n; i++) { for(j=mid; j<=mid+i; j++) { a[i][j] = 'D'; } for(j=mid; j>=mid-i; j--) { a[i][j] = 'D'; } } for(i=0; i<=mid; i++) { for(j=0; j<n; j++) { cout << a[i][j]; } cout << endl; } for(i=mid-1; i>=0; i--) { for(j=0; j<n; j++) { cout << a[i][j]; } cout << endl; } return 0; }
UVa 11936. The Lazy Lumberjacks
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define sf scanf
#define pf printf
#define PI 2*acos(0.0)
int main()
{
int t;
sf("%d",&t);
while(t--)
{
ll a, b, c;
sf("%lld%lld%lld", &a, &b, &c);
if(a+b>c && b+c>a && a+c>b)
pf("OK\n");
else
pf("Wrong!!\n");
}
return 0;
}
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define sf scanf
#define pf printf
#define PI 2*acos(0.0)
int main()
{
int t;
sf("%d",&t);
while(t--)
{
ll a, b, c;
sf("%lld%lld%lld", &a, &b, &c);
if(a+b>c && b+c>a && a+c>b)
pf("OK\n");
else
pf("Wrong!!\n");
}
return 0;
}
Thursday, April 30, 2015
485A - Factory(Codeforces)
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std ;
#define pf printf
#define sf scanf
#define loop(i, n) for(i=0; i<n; i++)
#define MAX 500
int main()
{
int a, m, i, rem;
while(sf("%d%d", &a, &m)==2)
{
loop(i, MAX)
{
rem = (a%m);
if(rem==0)
break;
a+=rem;
}
if(rem==0)
pf("Yes\n");
else
pf("No\n");
}
return 0;
}
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std ;
#define pf printf
#define sf scanf
#define loop(i, n) for(i=0; i<n; i++)
#define MAX 500
int main()
{
int a, m, i, rem;
while(sf("%d%d", &a, &m)==2)
{
loop(i, MAX)
{
rem = (a%m);
if(rem==0)
break;
a+=rem;
}
if(rem==0)
pf("Yes\n");
else
pf("No\n");
}
return 0;
}
Tuesday, April 14, 2015
474A. Keyboard (Codeforces)
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define pf printf
#define sf scanf
using namespace std;
int main()
{
string s = "qwertyuiopasdfghjkl;zxcvbnm,./'";
string s1;
int i, j, len;
char input;
sf("%c",&input);
cin >> s1;
len = s1.length();
if(input == 'R')
{
for(i=0; i<len; i++)
{
for(j=0; j<31; j++)
{
if(s1[i]== s[j])
{
pf("%c", s[j-1]);
}
}
}
pf("\n");
}
else if(input == 'L')
{
for(i=0; i<len; i++)
{
for(j=0; j<31; j++)
{
if(s1[i]== s[j])
{
pf("%c", s[j+1]);
}
}
}
pf("\n");
}
return 0;
}
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define pf printf
#define sf scanf
using namespace std;
int main()
{
string s = "qwertyuiopasdfghjkl;zxcvbnm,./'";
string s1;
int i, j, len;
char input;
sf("%c",&input);
cin >> s1;
len = s1.length();
if(input == 'R')
{
for(i=0; i<len; i++)
{
for(j=0; j<31; j++)
{
if(s1[i]== s[j])
{
pf("%c", s[j-1]);
}
}
}
pf("\n");
}
else if(input == 'L')
{
for(i=0; i<len; i++)
{
for(j=0; j<31; j++)
{
if(s1[i]== s[j])
{
pf("%c", s[j+1]);
}
}
}
pf("\n");
}
return 0;
}
Friday, April 10, 2015
466A - Cheap Travel (Codeforces)
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
#define sf scanf
#define pf printf
int min(int a, int b)
{
if(a<=b )
return a;
else
return b;
}
int main()
{
int n, m, a, b;
int ans, ans1, ans2;
while(cin >> n >> m >> a >> b)
{
if((m*a)<=b)
{
ans = a*n;
cout << ans << endl;
}
else
{
ans1 = ((n/m)*b) + b;
ans2 = ((n/m)*b) + (n%m)*a;
ans = min(ans1, ans2);
cout << ans << endl;
}
}
return 0;
}
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
#define sf scanf
#define pf printf
int min(int a, int b)
{
if(a<=b )
return a;
else
return b;
}
int main()
{
int n, m, a, b;
int ans, ans1, ans2;
while(cin >> n >> m >> a >> b)
{
if((m*a)<=b)
{
ans = a*n;
cout << ans << endl;
}
else
{
ans1 = ((n/m)*b) + b;
ans2 = ((n/m)*b) + (n%m)*a;
ans = min(ans1, ans2);
cout << ans << endl;
}
}
return 0;
}
Saturday, April 4, 2015
146 - ID Codes (UVa)
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000
#define pf printf
#define sf scanf
int main()
{
char s[MAX];
int len;
while(cin >> s)
{
cin.ignore();
if(s[0]=='#') break;
len = strlen(s);
if(next_permutation(s, s+len))
cout << s << endl;
else
cout << "No Successor" << endl;
}
return 0;
}
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAX 1000
#define pf printf
#define sf scanf
int main()
{
char s[MAX];
int len;
while(cin >> s)
{
cin.ignore();
if(s[0]=='#') break;
len = strlen(s);
if(next_permutation(s, s+len))
cout << s << endl;
else
cout << "No Successor" << endl;
}
return 0;
}
Subscribe to:
Posts (Atom)
Compare equality of two string in C
#include <stdio.h> #include<string.h> int main() { char* country = "Bangladesh"; char* country2; ...
-
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespac...
-
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<ve...
-
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> using namespace std; #define pf printf ...