Search Results

Search found 13 results on 1 pages for 'codechef'.

Page 1/1 | 1 

  • Codechef practice question help needed - find trailing zeros in a factorial

    - by manugupt1
    I have been working on this for 24 hours now, trying to optimize it. The question is how to find the number of trailing zeroes in factorial of a number in range of 10000000 and 10 million test cases in about 8 secs. The code is as follows: #include<iostream> using namespace std; int count5(int a){ int b=0; for(int i=a;i>0;i=i/5){ if(i%15625==0){ b=b+6; i=i/15625; } if(i%3125==0){ b=b+5; i=i/3125; } if(i%625==0){ b=b+4; i=i/625; } if(i%125==0){ b=b+3; i=i/125; } if(i%25==0){ b=b+2; i=i/25; } if(i%5==0){ b++; } else break; } return b; } int main(){ int l; int n=0; cin>>l; //no of test cases taken as input int *T = new int[l]; for(int i=0;i<l;i++) cin>>T[i]; //nos taken as input for the same no of test cases for(int i=0;i<l;i++){ n=0; for(int j=5;j<=T[i];j=j+5){ n+=count5(j); //no of trailing zeroes calculted } cout<<n<<endl; //no for each trialing zero printed } delete []T; } Please help me by suggesting a new approach, or suggesting some modifications to this one.

    Read the article

  • which is time consuming construct in following program?

    - by user388338
    while submitting a solution for practise problem 6(odd) i got TLE error but while using using print and scanf in place cin and cout my sol was submitted successfully with 0.77s time..i want to know how can i make it more efficient link to problem is codechef problem 6 #include<iostream> #include<cstdio> using namespace std; int main() {int n,N; scanf("%d",&n); for(int l=0;l<n;l++) { scanf("%d",&N); int i=0,x; if(N<=0) continue; for(;N>=(x=(2<<i));i++); printf("%d",x/2); cout<<"\n"; } }

    Read the article

  • Programming Practice/Test Contest?

    - by Emmanuel
    My situation: I'm on a programming team, and this year, we want to weed out the weak link by making a competition to get the best coder from our group of candidates. Focus is on IEEExtreme-like contests. What I've done: I've been trying already for 2 weeks to get a practice or test site, like UVa or codechef. The plan after I find one: Send them (the candidates) a list of direct links to the problems (making them the "contest's problem list) get them to email me their correct answers' code at the time the judge says they have solved it and accept the fastest one into the team. Issues: We had practiced on UVa already (on programming challenges too), so our former teammate (which will be in the candidate group) already has an advantage if we used it. Codechef has all it's answers public, and since it shows the latest ones it will be extremely hard to verify if the answer was copied. And I've found other sites, like SPOJ, but they share at least some problems with codechef, making them inherit the issue of Codechef So, what alternatives do you think there are? Any site that may work? Any place to get all stuff to set up a Mooshak or similar contest (as in the stuff to get the problems, instructions to set up the server itself are easy to google)? Any other idea?

    Read the article

  • Passing 2D array with variable dimensions as function argument

    - by TheCrazyProgrammer
    I just saw the following code among the successful submissions at codechef. http://www.codechef.com/viewplaintext/1595846 I used to think that float max(int n,int arr[n][n]) {....} is not allowed in C++ (as 'n' is a variable). My CodeBlocks (on windows) with MinGW [gcc 4.4] gives compile time error. that "error: array bound is not an integer constant. Then how can be such a solution be accepted by CodeChef's judge. Is there any special flag that allows us to do that in C++??? EDIT: A link showing status as AC (accepted) : http://www.codechef.com/viewsolution/1595846

    Read the article

  • Looking for a workaround for IE 6/7 "Unspecified Error" bug when accessing offsetParent; using ASP.N

    - by CodeChef
    I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of concept application. This page uses the ASP.NET AJAX UpdatePanel to do partial page updates. The page allows a user to drop an item into a trashcan div, which will invoke a postback that deletes a record from the database, then rebinds the list (and other controls) that the item was drug from. All of these elements (the draggable items and the trashcan div) are inside an ASP.NET UpdatePanel. Here is the dragging and dropping initialization script: function initDragging() { $(".person").draggable({helper:'clone'}); $("#trashcan").droppable({ accept: '.person', tolerance: 'pointer', hoverClass: 'trashcan-hover', activeClass: 'trashcan-active', drop: onTrashCanned }); } $(document).ready(function(){ initDragging(); var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(function() { initDragging(); }); }); function onTrashCanned(e,ui) { var id = $('input[id$=hidID]', ui.draggable).val(); if (id != undefined) { $('#hidTrashcanID').val(id); __doPostBack('btnTrashcan',''); } } When the page posts back, partially updating the UpdatePanel's content, I rebind the draggables and droppables. When I then grab a draggable with my cursor, I get an "htmlfile: Unspecified error." exception. I can resolve this problem in the jQuery library by replacing elem.offsetParent with calls to this function that I wrote: function IESafeOffsetParent(elem) { try { return elem.offsetParent; } catch(e) { return document.body; } } I also have to avoid calls to elem.getBoundingClientRect() as it throws the same error. For those interested, I only had to make these changes in the jQuery.fn.offset function in the Dimensions Plugin. My questions are: Although this works, are there better ways (cleaner; better performance; without having to modify the jQuery library) to solve this problem? If not, what's the best way to manage keeping my changes in sync when I update the jQuery libraries in the future? For, example can I extend the library somewhere other than just inline in the files that I download from the jQuery website. Update: @some It's not publicly accessible, but I will see if SO will let me post the relevant code into this answer. Just create an ASP.NET Web Application (name it DragAndDrop) and create these files. Don't forget to set Complex.aspx as your start page. You'll also need to download the jQuery UI drag and drop plug in as well as jQuery core Complex.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Complex.aspx.cs" Inherits="DragAndDrop.Complex" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script src="jquery-1.2.6.min.js" type="text/javascript"></script> <script src="jquery-ui-personalized-1.5.3.min.js" type="text/javascript"></script> <script type="text/javascript"> function initDragging() { $(".person").draggable({helper:'clone'}); $("#trashcan").droppable({ accept: '.person', tolerance: 'pointer', hoverClass: 'trashcan-hover', activeClass: 'trashcan-active', drop: onTrashCanned }); } $(document).ready(function(){ initDragging(); var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(function() { initDragging(); }); }); function onTrashCanned(e,ui) { var id = $('input[id$=hidID]', ui.draggable).val(); if (id != undefined) { $('#hidTrashcanID').val(id); __doPostBack('btnTrashcan',''); } } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="updContent" runat="server" UpdateMode="Always"> <ContentTemplate> <asp:LinkButton ID="btnTrashcan" Text="trashcan" runat="server" CommandName="trashcan" onclick="btnTrashcan_Click" style="display:none;"></asp:LinkButton> <input type="hidden" id="hidTrashcanID" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" /> <table> <tr> <td style="width: 300px;"> <asp:DataList ID="lstAllPeople" runat="server" DataSourceID="odsAllPeople" DataKeyField="ID"> <ItemTemplate> <div class="person"> <asp:HiddenField ID="hidID" runat="server" Value='<%# Eval("ID") %>' /> Name: <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' /> <br /> <br /> </div> </ItemTemplate> </asp:DataList> <asp:ObjectDataSource ID="odsAllPeople" runat="server" SelectMethod="SelectAllPeople" TypeName="DragAndDrop.Complex+DataAccess" onselecting="odsAllPeople_Selecting"> <SelectParameters> <asp:Parameter Name="filter" Type="Object" /> </SelectParameters> </asp:ObjectDataSource> </td> <td style="width: 300px;vertical-align:top;"> <div id="trashcan"> drop here to delete </div> <asp:DataList ID="lstPeopleToDelete" runat="server" DataSourceID="odsPeopleToDelete"> <ItemTemplate> ID: <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' /> <br /> Name: <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /> <br /> <br /> </ItemTemplate> </asp:DataList> <asp:ObjectDataSource ID="odsPeopleToDelete" runat="server" onselecting="odsPeopleToDelete_Selecting" SelectMethod="GetDeleteList" TypeName="DragAndDrop.Complex+DataAccess"> <SelectParameters> <asp:Parameter Name="list" Type="Object" /> </SelectParameters> </asp:ObjectDataSource> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> Complex.aspx.cs namespace DragAndDrop { public partial class Complex : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected List<int> DeleteList { get { if (ViewState["dl"] == null) { List<int> dl = new List<int>(); ViewState["dl"] = dl; return dl; } else { return (List<int>)ViewState["dl"]; } } } public class DataAccess { public IEnumerable<Person> SelectAllPeople(IEnumerable<int> filter) { return Database.SelectAll().Where(p => !filter.Contains(p.ID)); } public IEnumerable<Person> GetDeleteList(IEnumerable<int> list) { return Database.SelectAll().Where(p => list.Contains(p.ID)); } } protected void odsAllPeople_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["filter"] = this.DeleteList; } protected void odsPeopleToDelete_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["list"] = this.DeleteList; } protected void Button1_Click(object sender, EventArgs e) { foreach (int id in DeleteList) { Database.DeletePerson(id); } DeleteList.Clear(); lstAllPeople.DataBind(); lstPeopleToDelete.DataBind(); } protected void btnTrashcan_Click(object sender, EventArgs e) { int id = int.Parse(hidTrashcanID.Value); DeleteList.Add(id); lstAllPeople.DataBind(); lstPeopleToDelete.DataBind(); } } } Database.cs namespace DragAndDrop { public static class Database { private static Dictionary<int, Person> _people = new Dictionary<int,Person>(); static Database() { Person[] people = new Person[] { new Person("Chad") , new Person("Carrie") , new Person("Richard") , new Person("Ron") }; foreach (Person p in people) { _people.Add(p.ID, p); } } public static IEnumerable<Person> SelectAll() { return _people.Values; } public static void DeletePerson(int id) { if (_people.ContainsKey(id)) { _people.Remove(id); } } public static Person CreatePerson(string name) { Person p = new Person(name); _people.Add(p.ID, p); return p; } } public class Person { private static int _curID = 1; public int ID { get; set; } public string Name { get; set; } public Person() { ID = _curID++; } public Person(string name) : this() { Name = name; } } }

    Read the article

  • Configure Active Relying Party STS to Trust Multiple Identity Provider STSes

    - by CodeChef
    I am struggling with the configuration for the scenario below. I have a custom WCF/WIF STS (RP-STS) that provides security tokens to my WCF services RP-STS is an "Active" STS RP-STS acts as a claims transformation STS RP-STS trusts tokens from many customer-specific identity provider STSes (IdP-STS) When a WCF Client connects to a service it should authenticate with it's local IdP-STS The reading that I've done describes this as Home Realm Discovery. HRD is usually described within the context of web applications and Passive STSes. My questions is, for my situation, does the logic for choosing an IdP-STS endpoint belong in the RP-STS or the WCF Client application? I thought it belonged in the RP-STS, but I cannot figure out the configuration to make this happen. RP-STS has a single endpoint, but I cannot figure out how to add more than one trusted issuer per endpoint. Any guidance on this would be very appreciated (I'm out of useful keywords to Google.) Also, if I'm way off please offer alternative approaches. Thanks!

    Read the article

  • wsFederationHttpBinding over net.tcp

    - by CodeChef
    I have services that use net.tcp bindings (both streaming and buffered endpoints.) I'd like to add WIF federated security to those services, while continuing to use net.tcp bindings. I've tried to create custom bindings, but so far have been unsuccessful. Below is the general architecture that I'm attempting. I'm looking for the correct binding configuration to make this work. Client - WPF Application Relying party - WCF Service with net.tcp endpoints STS - WCF Service with http(s) endpoint

    Read the article

  • runtime error (SIGSEGV)

    - by vamsi2018
    hi, i would be happy to know why i got this error for the problem http://www.codechef.com/problems/AXR1P2 in codechef.com and my code is... include include int main() { int *num=0,n=0,i=0,max=0;char *s=""; int sum[9]={1,5,14,20,25,31,32,38,39},dsum[9]={1,7,8,14,19,25,26,32,33},unitdig=0; do { gets(s); *(num+i)=(int)atoi(s); i++; }while(s!='#'); max=i; for(i=0;i10) unitdig=33(n/10-1)+39+dsum[(n%10)-1]; else unitdig=sum[(n%10)-1]; printf("%d\n",unitdig%10); } getchar(); return 0;}

    Read the article

  • Online Judge System

    - by Deni Mf
    I'm planing to host a programing competition within my company, if the event is successful and there is a interest we plan to do this couple times a year. I've found the following self hosted platforms: http://www.domjudge.org/development http://sankhs.com/codejudge/ http://sharifjudge.ir/news/sharif-judge-12-released (does not support c#) And this online free service: http://www.codechef.com/hostyourcontest Can you share experience in hosting such event and what platforms did you used?

    Read the article

  • Which of these studies would benefit a CS student the most? [closed]

    - by user1265125
    Which of these extra-curricular studies would benefit a CS student the most? Algorithms Advanced OS programming Image processing Computer graphics Open source development Practicing on TopCoder or Codechef Something else? I realize the decision can be influenced by a number of factors, such as personal preference, what's currently hot in the jobs market, and what is likely to be in demand more in the future, however I would like to ask more experienced programmers which one(s) of these would be most beneficial to learn alongside all the required CS academics.

    Read the article

  • How to familiarize myself with Python

    - by Zel
    I am Python beginner. Started Python 1.5 months back. I downloaded the Python docs and read some part of the tutorial. I have been programming on codechef.com and solving problems of projecteuler. I am thinking of reading Introduction to algorithms and following this course on MIT opencourse ware as I haven't been getting much improvement in programming and I am wasting much time thinking just what should I do when faced with any programming problem. But I think that I still don't know the correct way to learn the language itself. Should I start the library reference or continue with Python tutorial? Is learning algorithms useful for language such as C and not so much for Python as it has "batteries included"? Are there some other resources for familiarization with the language and in general for learning to solve programming problems? Or do I need to just devote some more time?

    Read the article

  • Solving programming problems or contributing code?

    - by nischayn22
    What are the best skills to develop for a college graduate?? Should one spend hours/days trying to solve problems on codechef or topcoder or contribute code to open source organizations? My personal experience says solving problems teaches you how to make optimal code and learn new programming techniques (which someone else has researched and made available) to solve problems, whereas contributing to open source teaches you how to organize code (so others can work on it), use coding conventions and make "real" use of what you have learnt so far, blah blah!! Also another thing to note is that many companies are hiring today based on one's problem solving skills (Is this something I should worry about?) P.S. I have done little of online problem solving and little of code contribution (via GSoC), but left confused what I should continue doing (as doing both simultaneously isn't easy).

    Read the article

  • How do I start my career on a 3-year-old degree [on hold]

    - by Gabriel Burns
    I received my bachelor's degree in Com S (second major in math) in December 2011. I didn't have the best GPA (I was excellent at programming projects and had a deep understanding of CS concepts, but school is generally not the best format for displaying my strengths), and my only internship was with a now-defunct startup. After graduation I applied for several jobs, had a fair number of interviews, but never got hired. After a while, I got somewhat discouraged, and though I still said I was looking, and occasionally applied for something, my pace slowed down considerably. I remain convinced that software development is the right path for me, and that I could make a real contribution to someones work force, but I'm at a loss as to how I can convince anyone of this. My major problems are as follows. Lack of professional experience-- a problem for every entry-level programmer, I suppose, but everyone seems to want someone with a couple of years under their belt. Rustiness-- I've not really done any programming in about a year, and since school all I've really done is various programming competitions and puzzles. (codechef, hackerrank, etc.) I need a way to sharpen my skills. Long term unemployment-- while I had a basic fast-food job after I graduated, I've been truly unemployed for about a year now. Furthermore, no one has ever hired me as a programmer, and any potential employer is liable to wonder why. Old References-- my references are all college professors and one supervisor from my internship, none of whom I've had any contact with since I graduated. Confidence-- I have no doubt that I could be a good professional programmer, and make just about any employer glad that they hired me, but I'm aware of my red flags as a candidate, and have a hard time heading confidently into an interview. How can I overcome these problems and keep my career from being over before it starts?

    Read the article

1