Monthly Archives: February 2017

1012 – Guilty Prince

Problem Link Hints: Run Bfs to check for land First : store initial position of prince then run from this position highest only 4 move can be use (-1,0),(1,0),(0,-1),(0,1) and print the count;   View Code #include<bits/stdc++.h> using namespace std; … Continue reading

Rate this:

Posted in lightoj | Tagged , , | Leave a comment

300: Maya Calendar

Problem Link #Solution #include<iostream> #include<string.h> #include<stdio.h> #include<map> using namespace std; string day[20]={“pop”,”no”,”zip”,”zotz”,”tzec”,”xul”,”yoxkin”,”mol”,”chen”,”yax”,”zac”,”ceh”,”mac”,”kankin”,”muan”,”pax”,”koyab”,”cumhu”,”uayet”}; string month[20] = {“imix”, “ik”, “akbal”, “kan”, “chicchan”, “cimi”, “manik”, “lamat”, “muluk”, “ok”, “chuen”, “eb”, “ben”, “ix”, “mem”, “cib”, “caban”, “eznab”, “canac”, “ahau”}; int main() { int n,d,a; … Continue reading

Rate this:

Posted in Uncategorized | 1 Comment

USACO Solutions

  >>USACO Open 2009 Silver :Cow Line

Rate this:

Posted in Uncategorized | Leave a comment

USACO Open 2009 Silver :Cow Line

From BNUOJ #Solution #include<iostream> #include<stdio.h> #include<deque> using namespace std; int main() { std::ios::sync_with_stdio(false); int t,co=0,n=-1; cin>>t;deque<int>cows; while(t–) { char a,s; cin>>a; if(a==’A’) { cin>>s; co++; if(s==’L’) { cows.push_front(co); } else if(s==’R’) cows.push_back(co); } else{ cin>>s>>n; if(s==’R’) { for(int i=0;i<n;i++) cows.pop_back(); } … Continue reading

Rate this:

Posted in Uncategorized | Tagged , | Leave a comment

1138 – Trailing Zeroes (III)

Problem Link #Solution #include<bits/stdc++.h> using namespace std; int co,m; int zero(int n) { int q=5; co=0; int t=q; while(n/t)         //while(n) {                              //{ … Continue reading

Rate this:

Posted in Uncategorized | Leave a comment

11730 – Number Transformation

Problem Link Same Problem : LightOJ #Solution #include<bits/stdc++.h> using namespace std; #define N 1010 int prime[N]; void sieve(){ bool notprime[N]={true,true}; for(int i=2;i<=50;i++) for(int j=2*i;j<=N;j+=i) notprime[j]=true; int c=0; for(int i=2;i<N;i++) if(!notprime[i]) prime[c++]=i; } int bfs(int s,int t) { if(s==t) return 0; … Continue reading

Rate this:

Posted in Uncategorized, uva | Tagged , , | Leave a comment

424 – Integer Inquiry

#Problem Link Hints: BigInteger; #Solution import java.util.*; import java.math.*;class Main {public static void main(String args[]) { Scanner sc=new Scanner(System.in); BigInteger n=new BigInteger(“0”); while(sc.hasNext()) { BigInteger sum=sc.nextBigInteger(); if(sum.equals(BigInteger.valueOf(0))) break; n=n.add(sum); } System.out.println(n); } }

Rate this:

Posted in Uncategorized, uva | Tagged , | Leave a comment