-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
3,413 additions
and
3,413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
*.aux | ||
*.bak | ||
*.log | ||
*.ind | ||
*.bbl | ||
*.sav | ||
*.blg | ||
*.idx | ||
*.out | ||
*.ilg | ||
*.exe | ||
*.class | ||
*.stackdump | ||
*.aux | ||
*.bak | ||
*.log | ||
*.ind | ||
*.bbl | ||
*.sav | ||
*.blg | ||
*.idx | ||
*.out | ||
*.ilg | ||
*.exe | ||
*.class | ||
*.stackdump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
# cpbook-code | ||
CP4 Free Source Code Project (cpp/gnu++17, java/java11, py/python3, and ml/ocaml). | ||
|
||
This repo is expected to be much more up-to-date than CP4 itself, that will go out to public on 19 July 2020. | ||
|
||
All code in this repo are mostly (reasonably good, hopefully :) implementation of many well-known data structures and algorithms, | ||
so you are free to copy, adapt, use the code (in your next programming contest or any other coding project). | ||
|
||
Note to Computer Science educators worldwide: please include all the code discussed here in your plagiarism checker system as "excluded". | ||
Please do NOT test your students to just (re-)code these basic data structures/algorithms verbatim as that is just reinventing the wheel. | ||
Please test them with higher order thinking questions/problems that use these code instead. | ||
|
||
We will be thankful if you cite us (Steven Halim, Felix Halim, Suhendry Effendy) when you use code in this repo. | ||
|
||
This license is probably the most suitable: https://opensource.org/licenses/UPL | ||
# cpbook-code | ||
CP4 Free Source Code Project (cpp/gnu++17, java/java11, py/python3, and ml/ocaml). | ||
|
||
This repo is expected to be much more up-to-date than CP4 itself, that will go out to public on 19 July 2020. | ||
|
||
All code in this repo are mostly (reasonably good, hopefully :) implementation of many well-known data structures and algorithms, | ||
so you are free to copy, adapt, use the code (in your next programming contest or any other coding project). | ||
|
||
Note to Computer Science educators worldwide: please include all the code discussed here in your plagiarism checker system as "excluded". | ||
Please do NOT test your students to just (re-)code these basic data structures/algorithms verbatim as that is just reinventing the wheel. | ||
Please test them with higher order thinking questions/problems that use these code instead. | ||
|
||
We will be thankful if you cite us (Steven Halim, Felix Halim, Suhendry Effendy) when you use code in this repo. | ||
|
||
This license is probably the most suitable: https://opensource.org/licenses/UPL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
print(eval(input())) | ||
print(eval(input())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#include <bits/stdc++.h> // a good practice in CP | ||
using namespace std; // same as above | ||
int main() { | ||
int a, b, c, n; scanf("%d %d %d %d", &a, &b, &c, &n); // bug fix below | ||
printf(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ? | ||
"YES\n" : "NO\n"); // use ternary operator | ||
return 0; // for shorter code | ||
} | ||
#include <bits/stdc++.h> // a good practice in CP | ||
using namespace std; // same as above | ||
int main() { | ||
int a, b, c, n; scanf("%d %d %d %d", &a, &b, &c, &n); // bug fix below | ||
printf(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ? | ||
"YES\n" : "NO\n"); // use ternary operator | ||
return 0; // for shorter code | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import java.util.*; | ||
class moscowdream { | ||
public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | ||
int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), n = sc.nextInt(); | ||
System.out.println(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ? "YES" : "NO"); | ||
} | ||
} | ||
import java.util.*; | ||
class moscowdream { | ||
public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | ||
int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), n = sc.nextInt(); | ||
System.out.println(((a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3)) ? "YES" : "NO"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
open Scanf | ||
open Printf | ||
|
||
let () = | ||
scanf "%d %d %d %d\n" (fun a b c n -> | ||
if (a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3) then | ||
printf "YES\n" | ||
else | ||
printf "NO\n" | ||
) | ||
open Scanf | ||
open Printf | ||
|
||
let () = | ||
scanf "%d %d %d %d\n" (fun a b c n -> | ||
if (a >= 1) && (b >= 1) && (c >= 1) && (a+b+c >= n) && (n >= 3) then | ||
printf "YES\n" | ||
else | ||
printf "NO\n" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
a, b, c, n = map(int, input().split()) | ||
print("YES" if ((a >= 1) and (b >= 1) and (c >= 1) and (a+b+c >= n) and (n >= 3)) else "NO"); | ||
a, b, c, n = map(int, input().split()) | ||
print("YES" if ((a >= 1) and (b >= 1) and (c >= 1) and (a+b+c >= n) and (n >= 3)) else "NO"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import java.io.*; | ||
import java.util.*; | ||
import java.math.BigInteger; // in package java.math | ||
|
||
class Main { // UVa 10925 - Krakovia | ||
public static void main(String[] args) throws Exception { | ||
BufferedReader br = new BufferedReader( // use BufferedReader | ||
new InputStreamReader(System.in)); | ||
PrintWriter pw = new PrintWriter( // and PrintWriter | ||
new BufferedWriter(new OutputStreamWriter(System.out))); // = fast IO | ||
int caseNo = 0; | ||
while (true) { | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
int N = Integer.parseInt(st.nextToken()); // N bills | ||
int F = Integer.parseInt(st.nextToken()); // F friends | ||
if (N == 0 && F == 0) break; | ||
BigInteger sum = BigInteger.ZERO; // built-in constant | ||
for (int i = 0; i < N; ++i) { // sum the N large bills | ||
BigInteger V = new BigInteger(br.readLine()); // string constructor | ||
sum = sum.add(V); // BigInteger addition | ||
} | ||
pw.printf("Bill #%d costs ", ++caseNo); | ||
pw.printf(sum.toString()); | ||
pw.printf(": each friend should pay "); | ||
pw.printf(sum.divide(BigInteger.valueOf(F)).toString()); | ||
pw.printf("\n\n"); // divide to F friends | ||
} | ||
pw.close(); | ||
} | ||
} | ||
import java.io.*; | ||
import java.util.*; | ||
import java.math.BigInteger; // in package java.math | ||
|
||
class Main { // UVa 10925 - Krakovia | ||
public static void main(String[] args) throws Exception { | ||
BufferedReader br = new BufferedReader( // use BufferedReader | ||
new InputStreamReader(System.in)); | ||
PrintWriter pw = new PrintWriter( // and PrintWriter | ||
new BufferedWriter(new OutputStreamWriter(System.out))); // = fast IO | ||
int caseNo = 0; | ||
while (true) { | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
int N = Integer.parseInt(st.nextToken()); // N bills | ||
int F = Integer.parseInt(st.nextToken()); // F friends | ||
if (N == 0 && F == 0) break; | ||
BigInteger sum = BigInteger.ZERO; // built-in constant | ||
for (int i = 0; i < N; ++i) { // sum the N large bills | ||
BigInteger V = new BigInteger(br.readLine()); // string constructor | ||
sum = sum.add(V); // BigInteger addition | ||
} | ||
pw.printf("Bill #%d costs ", ++caseNo); | ||
pw.printf(sum.toString()); | ||
pw.printf(": each friend should pay "); | ||
pw.printf(sum.divide(BigInteger.valueOf(F)).toString()); | ||
pw.printf("\n\n"); // divide to F friends | ||
} | ||
pw.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import sys | ||
inputs = sys.stdin.read().splitlines() # make Python I/O faster | ||
caseNo = 1 | ||
ln = 0 | ||
while True: | ||
N, F = map(int, inputs[ln].split()) # N bills, F friends | ||
ln += 1 | ||
if N == 0 and F == 0: break | ||
sum = 0 # native support | ||
for _ in range(N): # sum the N large bills | ||
sum += int(inputs[ln]) # native Big Integer | ||
ln += 1 | ||
print("Bill #%d costs %d: each friend should pay %d\n" | ||
% (caseNo, sum, sum//F)) # integer division | ||
caseNo += 1 | ||
import sys | ||
inputs = sys.stdin.read().splitlines() # make Python I/O faster | ||
caseNo = 1 | ||
ln = 0 | ||
while True: | ||
N, F = map(int, inputs[ln].split()) # N bills, F friends | ||
ln += 1 | ||
if N == 0 and F == 0: break | ||
sum = 0 # native support | ||
for _ in range(N): # sum the N large bills | ||
sum += int(inputs[ln]) # native Big Integer | ||
ln += 1 | ||
print("Bill #%d costs %d: each friend should pay %d\n" | ||
% (caseNo, sum, sum//F)) # integer division | ||
caseNo += 1 |
Oops, something went wrong.