Posts

Showing posts from August, 2012

136 - Ugly Numbers

136 Accepted View Problem UVA Problem: 136 - Ugly Numbers Time Limit: 3.00 Seconds Program Language: C++ Publisher: http://www.uvaonlinejudge.org ♣ Try it Out :: #include<iostream> using namespace std; int main() { int p,q,r, i=1, P,Q,R, ugly[1501]={0}; ugly[0]=1, p=q=r=0; while(ugly[1499] == 0) { P = ugly[p]*2; Q = ugly[q]*3; R = ugly[r]*5; if(P<Q && P<R) {ugly[i++]=P; p++;} else if(Q<P && Q<R) {ugly[i++]=Q; q++;} else if(R<P && R<Q) {ugly[i++]=R; r++;} else if(P == Q) {q++;} else if(P == R) {r++;} else if(R == Q) {r++;} } cout<<"The 1500'th ugly number is "<<ugly[1499]<<"."<<endl; return(0); } ♣ Source Codes :: 136 - Ugly Numbers.cpp 136 - Ugly Numbers.java আবূ হুরাইরাহ (রাঃ) হতে বর্ণিত আছে, তিনি বলেন, নবী (সাল্লাল্

113 - Power of Cryptography

113 Accepted View Problem UVA Problem: 113 - Power of Cryptography Time Limit: 3.00 Seconds Program Language: C++ Publisher: http://www.uvaonlinejudge.org ♣ Try it Out :: #include<iostream> #include<cstdlib> #include<cstdio> #include<cmath> using namespace std; int main() { //freopen("113.in", "r", stdin); double n, p; while(cin>>n>>p) printf("%.0lf\n", pow(p,1/n)); return(0); } ♣ Source Codes :: 113 - Power of Cryptography.cpp 113 - Power of Cryptography.java

299 - Train Swapping

299 Accepted View Problem UVA Problem: 299 - Train Swapping Time Limit: 3.00 Seconds Program Language: C++ Publisher: http://www.uvaonlinejudge.org ♣ Try it Out :: #include<iostream> #include<cstdio> #include<cstdlib> #define FOR(i,n) for(int i=0; i<n; i++) using namespace std; int InsertionSort(int[], int); int main() { //freopen("299.in", "r", stdin); int N, Len; cin>>N; FOR(i,N) { cin>>Len; int Arr[Len]; FOR(j,Len) cin>>Arr[j]; cout<<"Optimal train swapping takes "<<InsertionSort(Arr,Len)<<" swaps."<<endl; } return 0; } int InsertionSort(int A[], int len) { int i, j, key, swaps = 0; for(j = 1; j <= len-1; j++) { key = A[j]; i = j - 1; while(i >= 0 && A[i] > key) { A[i+1] = A[i]; i--,

Best PTC Sites

Image
CashNhits - Trusted Admin Account Per Click Referal Click Cashout Cashout Time Ads/Day Payment Via Standard 0.002 - 0.0005 10% $ 0.60 72 hours 65+ AP / PP Premium 0.01 - 0.0005 up to 100% $ 0.50 instant 80 Proof 1 Invested: $ 0.00 Received: $ 0.00 Net Profit: 0 Join Now Incenria - Paid To Click Ads Account Per Click Referal Click Cashout Cashout Time Ads/Day Payment Via Standard 0.002 - 0.001 10% $ 1.00 7 days 10 AP / PP Premium 0.01 - 0.005 up to 100% $ 1.00 instant 10+ Proof 1 Invested: $ 0.00 Received: $ 0.00 Net Profit: 0 Join Now

C Program To Show Lenght Of A Word Using Function And Array

♣ Try it Out :: #include<stdio.h> #include<conio.h> int strLen(char *str) { int len=0; for(int i=0; str[i]!='\0'; i++) len++; return len; } int main() { char a[100]; printf("Please enter a word: "); scanf("%s", a); int L = strLen(a); printf("\nLenght = %d", L); getch(); return 0; } ♣ Output :: Please enter a word: Muhit Lenght = 5 ♣ Downloads :: Download source code Download executable file

Free Programming Books

Books Title File Size 6.87 MB 1.21 MB 2.98 MB