background preloader

Codeforces

Codeforces

France IOI Voir les cours et résoudre les problèmes en : Remarque : Les cours pour ce langage ne sont disponibles que jusqu'au chapitre 4, « Lecture de l'entrée ». Les corrections sont toutefois toujours fournies. OCaml est un langage de programmation fonctionnel inventé au milieu des années 1990. Remarque : Pour un débutant souhaitant apprendre Java, nous conseillons fortement de commencer par JavaScool, plus facile à apprendre, bien que fortement similaire. Java's Cool (alias JavaScool) est conçu spécifiquement pour l'apprentissage des bases de la programmation. Le parcours général permet de progresser à son rythme, en partant des bases de la programmation et en allant jusqu'à un niveau avancé en algorithmique. Le parcours lycée correspond au programme officiel et contient les 2 premiers niveaux du parcours général ainsi que des exercices d'application aux mathématiques. Cette page contient un certain nombre de cours destinés à accompagner les épreuves d'algorithmique.

Algorithms and Data Structures Algorithm: a process or set of rules used for calculation or problem-solving, esp. with a computer.Program: a series of coded instructions to control the operation of a computer or other machine. Example Problem: Find the greatest common divisor (GCD) of two integers, m and n.Euclid's Algorithm: while m is greater than zero: If n is greater than m, swap m and n. Subtract n from m. n is the GCD Program (in C): Correctness Why do we believe that this algorithm devised thousands of years ago, is correct? Given m>0 and n>0, let g = gcd(m,n). So the algorithm is correct, provided that it terminates. Termination At the start of each iteration of the loop, either n>m or m≥n. So the algorithm does terminate. Testing Having proved the algorithm to be correct, one might argue that there is no need to test it. Debugging code be inserted to print the values of m and n at the end of each iteration to confirm that they behave as expected. Complexity Time If m=n, there is just one iteration; this is the best-case.

KayvanMazaheri Expand Collapse (22 lines) #include <iostream> using namespace std; const int MAXN = 1e5 + 123; int magnet[MAXN]; int main() { int n; cin >> n; for(int i=0; i<n; i++) cin >> magnet[i]; int groups = 1; for(int i=1; i<n; i++) if (magnet[i] != magnet [i-1]) groups ++; cout << groups << endl; return 0; } b484cb3d9a550bdb9c57a2af38829e8f cpp True False Sep 16, 2013 at 03:04 PM /api/public/snipt/81297/ cf-344a-magnets "code forces. accepted", implementation Expand Collapse (74 lines) 63206e2a9f45134a5b83889bf015873a Mar 26, 2013 at 07:52 AM /api/public/snipt/58294/ sgu-553-sultans-pearls "binary search", accepted, dp, sgu Expand Collapse (62 lines) None Feb 07, 2013 at 02:55 PM

Tainix - Tu codes, tu progresses. Archive of Interesting Code The Archive of Interesting Code is an (ambitious) effort on my part to research, intuit, and code up every interesting algorithm and data structure ever invented. In doing so, I hope both to learn the mathematical techniques that power these technologies and to improve my skills as a programmer. In case you're curious what I'm someday hoping to having implemented on this page, you can check out my TODO list. If you're interested in using any of this code in your applications, feel free to do so! You don't need to cite me or this website as a source, though I would appreciate it if you did. Enjoy!

103. Traffic Lights 103. Traffic Lights Time limit per test: 0.25 second(s)Memory limit: 4096 kilobytes input: standardoutput: standard In the city of Dingilville the traffic is arranged in an unusual way. the travel times for all roads (integers) the durations of the two colors at each junction (integers) and the initial color of the light and the remaining time (integer) for this color to change at each junction.

DelphiForFun Home Practice and Learn - Google Code Jam On this page you can see results and code from past rounds of Google Code Jam, and you can try the problems for yourself. If you're new to Code Jam, try following the Quick-Start Guide. Where should I start? If you're new to programming contests, we highly recommend starting with the least difficult problems and moving up from there as you get more confident. Beware: the round that has the easiest problem A may have a very difficult problem B! As you get used to the platform, you can check how many people solved each problem in the "Submissions" box to the left of the dashboard, and use that as a rough gauge of difficulty. Here are some choice problems for new competitors: Africa 2010, Qualification Round: Store Credit, Reverse Words. Remember, if you get stuck you can look at someone else's solution (click a "solutions" link below) or join our mailing list and ask for help. Finding Solutions You can click a "solutions" link below, but those aren't really indexed in a helpful way. TopCoder

Related: