diff --git a/code_study/Baekjoon/c/15829.c b/code_study/Baekjoon/c/15829.c new file mode 100644 index 0000000..9b32901 --- /dev/null +++ b/code_study/Baekjoon/c/15829.c @@ -0,0 +1,19 @@ +#include + +int main() { + int l; + char s[51]; + scanf("%d",&l); + scanf("%s",s); + + long long hash = 0, ri = 1; + int m = 1234567891; + for(int i=0; s[i]!='\0'; i++) { + hash = (hash + (((s[i] - 'a' + 1)%m)*ri)%m)%m; + ri = (ri*31)%m; + } + + printf("%lld\n",hash); + + return 0; +} \ No newline at end of file diff --git a/code_study/Baekjoon/c/30802.c b/code_study/Baekjoon/c/30802.c new file mode 100644 index 0000000..9b32901 --- /dev/null +++ b/code_study/Baekjoon/c/30802.c @@ -0,0 +1,19 @@ +#include + +int main() { + int l; + char s[51]; + scanf("%d",&l); + scanf("%s",s); + + long long hash = 0, ri = 1; + int m = 1234567891; + for(int i=0; s[i]!='\0'; i++) { + hash = (hash + (((s[i] - 'a' + 1)%m)*ri)%m)%m; + ri = (ri*31)%m; + } + + printf("%lld\n",hash); + + return 0; +} \ No newline at end of file diff --git a/code_study/Baekjoon/js/15829.js b/code_study/Baekjoon/js/15829.js new file mode 100644 index 0000000..e775c48 --- /dev/null +++ b/code_study/Baekjoon/js/15829.js @@ -0,0 +1,16 @@ +const [l, s] = require("fs").readFileSync(0, "utf8").toString().trim().split('\n'); +let ri = 1, hash = 0; +const M = 1234567891; +for(let i=0; i acc + Math.ceil(val/t), 0); +console.log(total_t); + +const pencil_set = Math.floor(n/p); +const pencil = n%p; +console.log(pencil_set,pencil); \ No newline at end of file diff --git a/code_study/Baekjoon/python/15829.py b/code_study/Baekjoon/python/15829.py new file mode 100644 index 0000000..c87c86c --- /dev/null +++ b/code_study/Baekjoon/python/15829.py @@ -0,0 +1,8 @@ +l = input() +Hash = 0 +ri = 1 +M = 1234567891 +for c in input() : + Hash = (Hash + ((((ord(c) - ord('a') + 1)%M)*ri)%M))%M + ri = ri*31%M +print(Hash) \ No newline at end of file diff --git a/code_study/Baekjoon/python/30802.py b/code_study/Baekjoon/python/30802.py new file mode 100644 index 0000000..613906f --- /dev/null +++ b/code_study/Baekjoon/python/30802.py @@ -0,0 +1,5 @@ +n = int(input()) +size = map(int, input().split()) +t, p = map(int, input().split()) +print(sum((i+t-1)//t for i in size)) +print(n//p,n%p) \ No newline at end of file