Tuesday, June 20, 2017
Sunday, June 04, 2017
Solution - UVa 417
UVa online judge
problem:417
word index
problem:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=358
UVa 10018
UVa online judge
problem:10018
(reverse and add)
problem:https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=959
Friday, June 02, 2017
Tomi miah's probablity
Cpbook.subeen.com
problem:19
Tomi miah's probablity
Thursday, May 18, 2017
UVa online judge 694
UVa online judge
problem:694
( The Collatz sequence)
problem:
UVa online jude 12543
UVa online judge
problem:12543
(longest word)
problem(PDF):
Monday, May 15, 2017
UVa online judge 10970
UVa online judge
problem:10970
Big chocolate
problem:https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1911
Sunday, May 14, 2017
uva online judge 11461
UVa online judge
problem: 11461
problem link:
UVa online judge 543
UVA online judge 543
Goldbach's conjecture
https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=484
Solution:
#include<bits/stdc++.h>
using namespace std;
#define N 1000000
int primes[N];
void Sieve()
{
int i;
for(i=2; i<=N; i++)
primes[i] = 1;
primes[0] = primes[1] = 0;
int len = sqrt(N);
for(i = 2; i <= len; ++i)
{
if(primes[i])
{
for( int k = i * i; k <= N; k += i )
primes[k] = 0;
}
}
primes[2] = 0;
}
int main()
{
Sieve();
int n,b,a;
while(scanf("%d", &n)&&n)
{
for( a = 3; a < n; ++a)
{
if( primes[a] )
{
b = n - a;
if( primes[b] )
{
// printf("%d = %d + %d\n", n, a, b);
cout <<n<<" "<<"="<<" "<<a<<" "<<"+"<<" "<<b<<endl;
break;
}
}
}
if(a+b!=n)
// printf("Goldbach's conjecture is wrong\n");
cout <<"Goldbach's conjecture is wrong"<< endl;
}
return 0;
}
Friday, May 12, 2017
UVa online judge 11876 N+NOD(N)
UVA online judge
problem:11876
N+ NOD (N)
problem link(PDF):
https://uva.onlinejudge.org/external/118/11876.pdf
SOLUTION:
#include<bits/stdc++.h>
using namespace std;
bool prime[1000009];
vector<int>num;
vector<int>pr;
int binary(int a)
{
int mid,L=0,u=num.size()-1;
while(L<=u)
{
mid=(u+L)/2;
if(a>num[mid])
L=mid+1;
else if(a<num[mid])
u=mid-1;
else return mid;
}
return mid;
}
Sunday, May 07, 2017
Solution to Uva problem 11530 - SMS Typing
Problem link:: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2525
soliution ::
#include<bits/stdc++.h>
using namespace std;
int main()
{
map< char,int >mp;
int n,ans;
string s;
mp['a']=1,mp['b']=2,mp['c']=3,mp['d']=1,mp['e']=2,mp['f']=3,mp['g']=1,mp['h']=2,mp['i']=3,mp['j']=1,mp['k']=2,mp['l']=3,mp['m']=1;
mp['n']=2,mp['o']=3,mp['p']=1,mp['q']=2,mp['r']=3,mp['s']=4,mp['t']=1,mp['u']=2,mp['v']=3,mp['w']=1,mp['x']=2,mp['y']=3,mp['z']=4;
mp[' ']=1,mp['\n']=0;
cin>>n;
getchar();
for(int i=0;i<n;i++)
{
ans=0;
getline(cin,s);
for(int i=0;i<s.size();i++)
{
ans=ans+mp[s[i]];
}
cout<<"Case #"<<i+1<<": "<<ans<<endl;
}
return 0;
}
/*this problem solution is solved with mapping if you don't know mapping then you will fail to undrstand so stay with us to know about mapping */
/* if you don't know about cin && cout put scanf instead of cin && printf instead of cout. Both works the same. */
Saturday, April 29, 2017
UVA ONLINE JUDGE 488
UVA online JUDGE
PROBLEM:488
(TRIANGLE WAVE)
PROBLEM LINK:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=429
Solution:
#include<bits/stdc++.h> using namespace std; int main()
{
UVA ONLINE JUDGE PROBLEM 11636
UVA ONLINE JUDGE
PROBLEM 11636
Hello World!
Problem link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2683
Solution:
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n,j;
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n,j;
Subscribe to:
Posts (Atom)