Posts

Solution - UVa Problem 1585 - Score

আলোচনাঃ Problem Link Here. সল্যুশন্সঃ #include<bits/stdc++.h> using namespace std; int main(){ int T; cin >> T; for(int i=1; i<=T; i++) { char w[80]; int score=0, nS=0, j; cin >> w; for(j=0; w[j]; j++) { if((w[j] == 'O')) { score = score +1 + nS; nS = nS+1; } else if(w[j] == 'X') nS = 0; } cout << score << endl; } return 0; }

Solution - UVa Problem 11942 - Lumberjack Sequencing

আলোচনাঃ Problem Link Here. সল্যুশন্সঃ #include<iostream> using namespace std; int main() { int t; cin >> t; for(int i=1; i<=t; i++){ bool aord = false; bool fl = false; int nm[10]; for(int j=0; j<=9; j++){ cin >> nm[j]; int k = j; if(k>1){ if(nm[j]>=nm[j-1] && nm[j-1]>=nm[j-2]) aord = true; else if(nm[j]<=nm[j-1] && nm[j-1]<=nm[j-2]) aord = true; else aord = false; if(aord == false) fl = true; } } if(i==1) cout << "Lumberjacks:" << endl; if(fl==true) cout << "Unordered" << endl; else cout << "Ordered" << endl; } return 0; }

Solution - UVa Problem 494 - Kindergarten Counting Game

আলোচনাঃ সল্যুশন্সঃ #include<bits/stdc++.h> using namespace std; int main(){ char s[10000]; int cnt=0; bool w = false; while(gets(s)){ for(int j=0; s[j]; j++){ if(s[j]>='a' && s[j]<='z' || s[j]>='A' && s[j]<='Z'){ w = true; } else { if(w==true){ cnt++; w = false; } } } cout << cnt << endl; cnt = 0; } return 0; }

Solution - UVa Problem 11364 - Parking

আলোচনাঃ সল্যুশন্সঃ #include<bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; for(int i=1; i<=t; i++){ int n; cin >> n; int x[n]; int mx,mn; for(int j=0; j<n; j++){ cin >> x[j]; if(j==0){ mx = x[0]; mn = x[0]; } if(x[j]>=mx) mx = x[j]; if(x[j]<=mn) mn = x[j]; } cout << (mx-mn)*2 << endl; } return 0; }

Solution - UVa Problem 11044 - Searching for Nessy

আলোচনাঃ চিত্র এর দিকে তাকালে বুঝা যাচ্ছে, একেকটা গ্রিড সাইজ ৩*৩। এখন আপনি যে Row*Column ইনপুট নিবেন তা ৩ দিয়ে ভাগ করে ভাগফলকে উভয় রো আর কলামের সাথে গুন করে দিন। বুঝেন নাই? মানে ইনপুট নিলেন ৯ এবং ১৩। এখন কলাম ৯ কে ৩ দিয়ে ভাগ করলে হয় ৩ আর ১৩ কে ৩ দিয়ে ভাগ করলে হয় ৪। এই ৩ আর ৪ গুন করলে হয় ১২। That's your goal... :) সল্যুশন্সঃ #include<bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; for(int i=1; i<=t; i++){ int n,m; cin >> n >> m; cout << (n/3)*(m/3) << endl; } return 0; }

Solution - UVa Problem 10550 - Combination Lock

আলোচনাঃ যত কম স্টেপে আপনি এক পজিসন থেকে আরেক পজিশন এ যেতে পারেন সেটা ক্যালকুলেট করতে হবে। বুঝেন নাই? ধরুন, a=0, b=30. এবার, Lock এর চিত্রতে যদি খেয়াল করেন দেখবেন a থেকে b তে যেতে ক্লক ওয়াইস লাগবে ৩০ স্টেপ বাট কাউন্টারক্লক ওয়াইস লাগবে ১০ স্টেপ। সো আপনাকে ১০ ই কাউন্ট করতে হবে। ইনপুট ১ এর ক্ষেত্রে, ০ ৩০ ০ ৩০। সো আপনার ক্যালকুলেশন হবে... ৩৬০*২+১০*৯+৩৬০+১০*৯+১০*৯ = ১৩৫০। এখানে ৯ হচ্ছে ৩৬০/৪০=৯ ডিগ্রী :) সল্যুশন্সঃ #include<iostream> using namespace std; int main(){ int a,b,c,d,t1,t2,t3; while(cin >> a >> b >> c >> d) { if(a==0&&b==0&&c==0&&d==0) break; if(a<b) t1=40-(b-a); else t1= a-b; if(b>c) t2=40-(b-c); else t2= c-b; if(c<d) t3=40-(d-c); else t3=c-d; cout << 360*3+(t1+t2+t3)*9 << endl; } return 0; }

Solution - UVa Problem 1124 - Celebrity jeopardy

সল্যুশন্সঃ #include<bits/stdc++.h> using namespace std; int main(){ char s[1000]; while(gets(s)){ cout << s << endl; } return 0; } আলোচনাঃ কিছুই ভাবতে হবে না। যা ইনপুট নিবেন চোখ বুঝে তা আউটপুট দিলে ই AC.