/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive, spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, tc, kk=1, x, y; string s; cin>>tc; while(tc--) { cin>>n; set<int>st; for(int i=0;i<n;i++) { cin>>x>>y; st.insert(abs(x-y)); } if(kk>1) cout<<"\n"; if(st.size()==1) cout<<"yes\n"; else cout<<"no\n"; kk++; } return 0; }
Friday, 28 November 2014
UVA 10963 The Swallowing Ground Solution
UVa 10114 - Loansome Car Buyer Solution (HDU 1309, ZOJ 1706, POJ 1571, UVALive 5332, Regionals 1999 >> North America - Mid-Central USA)
/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive, spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); double tmonth, downPay, price, interest[105], owe; int k, m; while(cin>>tmonth>>downPay>>price>>k && tmonth>=0) { owe=price; double monthlyPay=price/(double) tmonth; price+=downPay; for(int i=0;i<=tmonth;i++) interest[i]=-1; for(int i=0;i<k;i++) { cin>>m; cin>>interest[m]; } for(int i=1;i<=tmonth;i++) if(interest[i]==-1) interest[i]=interest[i-1]; int ans=-1; int i=0; while(ans==-1) { price=price-price*interest[i]; if(price>owe) ans=i; owe-=monthlyPay; i++; //cout<<interest[i]<<endl; } cout<<ans<<" month"; if(ans!=1) cout<<"s"; cout<<"\n"; } return 0; }
UVa 12279 - Emoogle Balance Solution (UVALive 4853, Regionals 2010 >> Asia - Dhaka)
/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive, spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 #define nl <<"\n" int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, tc, kk=1, x; string s; while(cin>>n && n) { int cnt=0; for(int i=0;i<n;i++) { cin>>x; if(x) cnt++; else cnt--; } cout<<"Case "<<kk++<<": "<<cnt nl; } return 0; }
UVa 11498 - Division of Nlogonia Solution
/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive, spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, tc, x, xx, y, yy; string s; while(cin>>n && n) { cin>>x>>y; for(int i=0;i<n;i++) { cin>>xx>>yy; //xx-=x; //yy-=y; if(xx==x || yy==y) cout<<"divisa\n"; else if(xx>x && yy>y) cout<<"NE\n"; else if(xx<x && yy>y) cout<<"NO\n"; else if(xx>x && yy<y) cout<<"SE\n"; else cout<<"SO\n"; } } return 0; }
Thursday, 27 November 2014
UVA 11364 Parking Solution (ZOJ - 2878, POJ - 3632, HDU - 1673)
/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive, spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, tc, arr[22]; string s; cin>>tc; while(tc--) { cin>>n; for(int i=0;i<n;i++) cin>>arr[i]; sort(arr, arr+n); int dist=0; for(int i=1;i<n;i++) dist+=(arr[i]-arr[i-1]); dist*=2; cout<<dist<<"\n"; } return 0; }
UVA 11044 Searching for Nessy Solution
/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive, spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, m, tc; string s; cin>>tc; while(tc--) { cin>>n>>m; //n-=2; //m-=2; //cout<<ceil((double)n/3)*ceil((double)m/3)<<"\n"; cout<<(n/3)*(m/3)<<"\n"; } return 0; }
UVA 10550 Combination Lock Solution (POJ 2304, ZOJ 1928)
/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive / spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, a, b, c, d; string s; while(cin>>a>>b>>c>>d) { if(!a && !b && !c && !d) break; int ans=1080; if(a<b) ans+=(40+a-b)*9; else ans+=(a-b)*9; if(b>c) ans+=(40+c-b)*9; else ans+=(c-b)*9; if(c<d) ans+=(40+c-d)*9; else ans+=(c-d)*9; cout<<ans<<"\n"; } return 0; }
Subscribe to:
Posts (Atom)