20250624 baekjoon
This commit is contained in:
parent
fb8b0b2197
commit
35cc79f065
19
code_study/Baekjoon/c/15829.c
Normal file
19
code_study/Baekjoon/c/15829.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
19
code_study/Baekjoon/c/30802.c
Normal file
19
code_study/Baekjoon/c/30802.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
16
code_study/Baekjoon/js/15829.js
Normal file
16
code_study/Baekjoon/js/15829.js
Normal file
@ -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<Number(l); i++) {
|
||||
hash = (hash + (((s[i].charCodeAt() - 'a'.charCodeAt() + 1)%M)*ri))%M;
|
||||
ri = (ri*31)%M;
|
||||
}
|
||||
console.log(hash);
|
||||
|
||||
// const M = BigInt(1234567891);
|
||||
// let hash = BigInt(0), ri = BigInt(1);
|
||||
// for(let c of s) {
|
||||
// hash += BigInt((c.charCodeAt() - 'a'.charCodeAt() + 1)) * ri;
|
||||
// ri *= BigInt(31);
|
||||
// }
|
||||
// console.log(hash%M);
|
||||
11
code_study/Baekjoon/js/30802.js
Normal file
11
code_study/Baekjoon/js/30802.js
Normal file
@ -0,0 +1,11 @@
|
||||
const input = require("fs").readFileSync(0,"utf8").toString().trim().split('\n');
|
||||
const n = Number(input[0]);
|
||||
const size = input[1].split(' ').map(Number);
|
||||
const [t, p] = input[2].split(' ').map(Number);
|
||||
|
||||
const total_t = size.reduce((acc,val) => 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);
|
||||
8
code_study/Baekjoon/python/15829.py
Normal file
8
code_study/Baekjoon/python/15829.py
Normal file
@ -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)
|
||||
5
code_study/Baekjoon/python/30802.py
Normal file
5
code_study/Baekjoon/python/30802.py
Normal file
@ -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)
|
||||
Loading…
x
Reference in New Issue
Block a user