20250624 baekjoon

This commit is contained in:
songyc macbook 2025-06-24 20:57:55 +09:00
parent fb8b0b2197
commit 35cc79f065
6 changed files with 78 additions and 0 deletions

View 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;
}

View 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;
}

View 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);

View 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);

View 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)

View 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)